diff --git a/db/ddlutils/oracle/functions/C_Invoice_Discount.sql b/db/ddlutils/oracle/functions/C_Invoice_Discount.sql index 797ae2dc48..81844857e8 100644 --- a/db/ddlutils/oracle/functions/C_Invoice_Discount.sql +++ b/db/ddlutils/oracle/functions/C_Invoice_Discount.sql @@ -25,15 +25,16 @@ AS v_GrandTotal NUMBER; v_TotalLines NUMBER; v_C_PaymentTerm_ID NUMBER(10); + v_C_Currency_ID NUMBER(10); v_DocDate DATE; v_PayDate DATE := SysDate; v_IsPayScheduleValid CHAR(1); BEGIN SELECT ci.IsDiscountLineAmt, i.GrandTotal, i.TotalLines, - i.C_PaymentTerm_ID, i.DateInvoiced, i.IsPayScheduleValid + i.C_PaymentTerm_ID, i.DateInvoiced, i.IsPayScheduleValid, C_Currency_ID INTO v_IsDiscountLineAmt, v_GrandTotal, v_TotalLines, - v_C_PaymentTerm_ID, v_DocDate, v_IsPayScheduleValid + v_C_PaymentTerm_ID, v_DocDate, v_IsPayScheduleValid, v_C_Currency_ID FROM AD_ClientInfo ci, C_Invoice i WHERE ci.AD_Client_ID=i.AD_Client_ID AND i.C_Invoice_ID=p_C_Invoice_ID; @@ -64,11 +65,11 @@ BEGIN END IF; -- return discount amount - RETURN paymentTermDiscount (v_Amount, 0, v_C_PaymentTerm_ID, v_DocDate, p_PayDate); + RETURN paymentTermDiscount (v_Amount, v_C_Currency_ID, v_C_PaymentTerm_ID, v_DocDate, p_PayDate); -- Most likely if invoice not found EXCEPTION WHEN OTHERS THEN RETURN NULL; END invoiceDiscount; -/ \ No newline at end of file +/ diff --git a/db/ddlutils/postgresql/functions/Acct_Balance.sql b/db/ddlutils/postgresql/functions/Acct_Balance.sql index 99766caa9c..f1a696d9f6 100644 --- a/db/ddlutils/postgresql/functions/Acct_Balance.sql +++ b/db/ddlutils/postgresql/functions/Acct_Balance.sql @@ -35,7 +35,5 @@ BEGIN END; -$body$ LANGUAGE plpgsql; - +$body$ LANGUAGE plpgsql STABLE; - diff --git a/db/ddlutils/postgresql/functions/Add_Months.sql b/db/ddlutils/postgresql/functions/Add_Months.sql index aba7aa2781..b9a071f997 100644 --- a/db/ddlutils/postgresql/functions/Add_Months.sql +++ b/db/ddlutils/postgresql/functions/Add_Months.sql @@ -9,5 +9,6 @@ BEGIN return cast(datetime + cast(duration as interval) as date); END; $BODY$ -LANGUAGE 'plpgsql' +LANGUAGE 'plpgsql' IMMUTABLE ; + diff --git a/db/ddlutils/postgresql/functions/C_BPartner_RemitLocation.sql b/db/ddlutils/postgresql/functions/C_BPartner_RemitLocation.sql index 28d270811f..a2ea163d7c 100644 --- a/db/ddlutils/postgresql/functions/C_BPartner_RemitLocation.sql +++ b/db/ddlutils/postgresql/functions/C_BPartner_RemitLocation.sql @@ -20,5 +20,5 @@ BEGIN END; -$body$ LANGUAGE plpgsql; - +$body$ LANGUAGE plpgsql STABLE; + diff --git a/db/ddlutils/postgresql/functions/C_Currency_Base.sql b/db/ddlutils/postgresql/functions/C_Currency_Base.sql index 09f3e0fa34..92de5e2de0 100755 --- a/db/ddlutils/postgresql/functions/C_Currency_Base.sql +++ b/db/ddlutils/postgresql/functions/C_Currency_Base.sql @@ -48,4 +48,5 @@ BEGIN RETURN currencyConvert (p_Amount, p_CurFrom_ID, v_CurTo_ID, p_ConvDate, null, p_Client_ID, p_Org_ID); END; -$body$ LANGUAGE plpgsql; \ No newline at end of file +$body$ LANGUAGE plpgsql STABLE; + diff --git a/db/ddlutils/postgresql/functions/C_Currency_Convert.sql b/db/ddlutils/postgresql/functions/C_Currency_Convert.sql index 27c3382a75..b89114d5d9 100644 --- a/db/ddlutils/postgresql/functions/C_Currency_Convert.sql +++ b/db/ddlutils/postgresql/functions/C_Currency_Convert.sql @@ -55,8 +55,5 @@ BEGIN END; -$body$ LANGUAGE plpgsql; - - - +$body$ LANGUAGE plpgsql STABLE; diff --git a/db/ddlutils/postgresql/functions/C_Currency_Rate.sql b/db/ddlutils/postgresql/functions/C_Currency_Rate.sql index ea305d1d02..9b9827d6e9 100644 --- a/db/ddlutils/postgresql/functions/C_Currency_Rate.sql +++ b/db/ddlutils/postgresql/functions/C_Currency_Rate.sql @@ -175,4 +175,5 @@ EXCEPTION WHEN OTHERS THEN END; -$body$ LANGUAGE plpgsql; +$body$ LANGUAGE plpgsql STABLE; + diff --git a/db/ddlutils/postgresql/functions/C_Currency_Round.sql b/db/ddlutils/postgresql/functions/C_Currency_Round.sql index dc8bd435b6..cc056c4f4e 100644 --- a/db/ddlutils/postgresql/functions/C_Currency_Round.sql +++ b/db/ddlutils/postgresql/functions/C_Currency_Round.sql @@ -57,6 +57,5 @@ BEGIN END; $BODY$ - LANGUAGE 'plpgsql' VOLATILE; + LANGUAGE 'plpgsql' STABLE; -ALTER FUNCTION currencyround(p_amount numeric, p_curto_id numeric, p_costing character varying) OWNER TO adempiere; diff --git a/db/ddlutils/postgresql/functions/C_Invoice_Discount.sql b/db/ddlutils/postgresql/functions/C_Invoice_Discount.sql index b7f83bdd96..6915dca361 100644 --- a/db/ddlutils/postgresql/functions/C_Invoice_Discount.sql +++ b/db/ddlutils/postgresql/functions/C_Invoice_Discount.sql @@ -29,15 +29,16 @@ DECLARE v_GrandTotal NUMERIC; v_TotalLines NUMERIC; v_C_PaymentTerm_ID NUMERIC(10); + v_C_Currency_ID NUMERIC(10); v_DocDate timestamp with time zone; v_PayDate timestamp with time zone := now(); v_IsPayScheduleValid CHAR(1); BEGIN SELECT ci.IsDiscountLineAmt, i.GrandTotal, i.TotalLines, - i.C_PaymentTerm_ID, i.DateInvoiced, i.IsPayScheduleValid + i.C_PaymentTerm_ID, i.DateInvoiced, i.IsPayScheduleValid, C_Currency_ID INTO v_IsDiscountLineAmt, v_GrandTotal, v_TotalLines, - v_C_PaymentTerm_ID, v_DocDate, v_IsPayScheduleValid + v_C_PaymentTerm_ID, v_DocDate, v_IsPayScheduleValid, v_C_Currency_ID FROM AD_ClientInfo ci, C_Invoice i WHERE ci.AD_Client_ID=i.AD_Client_ID AND i.C_Invoice_ID=p_C_Invoice_ID; @@ -69,7 +70,7 @@ BEGIN END IF; -- return discount amount - RETURN paymentTermDiscount (v_Amount, 0, v_C_PaymentTerm_ID, v_DocDate, p_PayDate); + RETURN paymentTermDiscount (v_Amount, v_C_Currency_ID, v_C_PaymentTerm_ID, v_DocDate, p_PayDate); -- Most likely if invoice not found EXCEPTION @@ -77,6 +78,5 @@ EXCEPTION RETURN NULL; END; -$body$ LANGUAGE plpgsql; +$body$ LANGUAGE plpgsql STABLE; - diff --git a/db/ddlutils/postgresql/functions/C_Invoice_Open.sql b/db/ddlutils/postgresql/functions/C_Invoice_Open.sql index 719d9a9ed2..0b175de98e 100644 --- a/db/ddlutils/postgresql/functions/C_Invoice_Open.sql +++ b/db/ddlutils/postgresql/functions/C_Invoice_Open.sql @@ -116,5 +116,6 @@ BEGIN END; $BODY$ -LANGUAGE 'plpgsql' +LANGUAGE 'plpgsql' STABLE ; + diff --git a/db/ddlutils/postgresql/functions/C_Invoice_OpenToDate.sql b/db/ddlutils/postgresql/functions/C_Invoice_OpenToDate.sql index 4e01d94580..f6a11d02b6 100644 --- a/db/ddlutils/postgresql/functions/C_Invoice_OpenToDate.sql +++ b/db/ddlutils/postgresql/functions/C_Invoice_OpenToDate.sql @@ -132,7 +132,8 @@ BEGIN RETURN v_TotalOpenAmt; END; $BODY$ - LANGUAGE 'plpgsql' ; + LANGUAGE 'plpgsql' STABLE; + CREATE OR REPLACE FUNCTION InvoiceopenToDate ( @@ -233,4 +234,5 @@ BEGIN RETURN v_TotalOpenAmt; END; $BODY$ - LANGUAGE 'plpgsql' ; \ No newline at end of file + LANGUAGE 'plpgsql' STABLE; + diff --git a/db/ddlutils/postgresql/functions/C_Invoice_Paid.sql b/db/ddlutils/postgresql/functions/C_Invoice_Paid.sql index aaf311e60e..9ddc1ba394 100644 --- a/db/ddlutils/postgresql/functions/C_Invoice_Paid.sql +++ b/db/ddlutils/postgresql/functions/C_Invoice_Paid.sql @@ -77,5 +77,5 @@ BEGIN RETURN v_PaymentAmt * v_MultiplierAP; END; -$body$ LANGUAGE plpgsql; - +$body$ LANGUAGE plpgsql STABLE; + diff --git a/db/ddlutils/postgresql/functions/C_Invoice_PaidToDate.sql b/db/ddlutils/postgresql/functions/C_Invoice_PaidToDate.sql index ff576e9646..7974e7b639 100644 --- a/db/ddlutils/postgresql/functions/C_Invoice_PaidToDate.sql +++ b/db/ddlutils/postgresql/functions/C_Invoice_PaidToDate.sql @@ -85,4 +85,5 @@ BEGIN RETURN v_PaymentAmt * v_MultiplierAP; END; $BODY$ -LANGUAGE 'plpgsql' ; +LANGUAGE 'plpgsql' STABLE; + diff --git a/db/ddlutils/postgresql/functions/C_PaymentTerm_Discount.sql b/db/ddlutils/postgresql/functions/C_PaymentTerm_Discount.sql index 3812f261a1..5fcbb88256 100644 --- a/db/ddlutils/postgresql/functions/C_PaymentTerm_Discount.sql +++ b/db/ddlutils/postgresql/functions/C_PaymentTerm_Discount.sql @@ -80,5 +80,5 @@ BEGIN RETURN Discount; END; -$body$ LANGUAGE plpgsql; - +$body$ LANGUAGE plpgsql STABLE; + diff --git a/db/ddlutils/postgresql/functions/C_PaymentTerm_DueDate.sql b/db/ddlutils/postgresql/functions/C_PaymentTerm_DueDate.sql index ddc956e955..8b904e50e2 100644 --- a/db/ddlutils/postgresql/functions/C_PaymentTerm_DueDate.sql +++ b/db/ddlutils/postgresql/functions/C_PaymentTerm_DueDate.sql @@ -45,5 +45,6 @@ BEGIN RETURN DueDate; END; $BODY$ -LANGUAGE 'plpgsql' +LANGUAGE 'plpgsql' STABLE ; + diff --git a/db/ddlutils/postgresql/functions/C_PaymentTerm_DueDays.sql b/db/ddlutils/postgresql/functions/C_PaymentTerm_DueDays.sql index 37ade5b826..7651987450 100644 --- a/db/ddlutils/postgresql/functions/C_PaymentTerm_DueDays.sql +++ b/db/ddlutils/postgresql/functions/C_PaymentTerm_DueDays.sql @@ -116,7 +116,5 @@ BEGIN RETURN Days; END; -$body$ LANGUAGE plpgsql; +$body$ LANGUAGE plpgsql STABLE; - - diff --git a/db/ddlutils/postgresql/functions/C_Payment_Allocated.sql b/db/ddlutils/postgresql/functions/C_Payment_Allocated.sql index a641b7514a..b163764d71 100644 --- a/db/ddlutils/postgresql/functions/C_Payment_Allocated.sql +++ b/db/ddlutils/postgresql/functions/C_Payment_Allocated.sql @@ -74,6 +74,5 @@ BEGIN RETURN v_AllocatedAmt; END; -$body$ LANGUAGE plpgsql; +$body$ LANGUAGE plpgsql STABLE; - diff --git a/db/ddlutils/postgresql/functions/C_Payment_Available.sql b/db/ddlutils/postgresql/functions/C_Payment_Available.sql index 6c9b80428e..b248027b51 100644 --- a/db/ddlutils/postgresql/functions/C_Payment_Available.sql +++ b/db/ddlutils/postgresql/functions/C_Payment_Available.sql @@ -74,4 +74,5 @@ BEGIN RETURN v_AvailableAmt; END; -$body$ LANGUAGE plpgsql; +$body$ LANGUAGE plpgsql STABLE; + diff --git a/db/ddlutils/postgresql/functions/ProductAttribute.sql b/db/ddlutils/postgresql/functions/ProductAttribute.sql index 34b58d2c2b..74d7027e4f 100644 --- a/db/ddlutils/postgresql/functions/ProductAttribute.sql +++ b/db/ddlutils/postgresql/functions/ProductAttribute.sql @@ -88,5 +88,5 @@ BEGIN RETURN v_Name; END; -$body$ LANGUAGE plpgsql; - +$body$ LANGUAGE plpgsql STABLE; + diff --git a/db/ddlutils/postgresql/functions/addDays.sql b/db/ddlutils/postgresql/functions/addDays.sql index e108e28c50..9045d79ec5 100644 --- a/db/ddlutils/postgresql/functions/addDays.sql +++ b/db/ddlutils/postgresql/functions/addDays.sql @@ -30,11 +30,12 @@ BEGIN duration = days || ' day'; return cast(date_trunc('day',datetime) + cast(duration as interval) as date); END; -$$ LANGUAGE plpgsql; +$$ LANGUAGE plpgsql IMMUTABLE; CREATE OR REPLACE FUNCTION subtractdays (day TIMESTAMP WITH TIME ZONE, days NUMERIC) RETURNS DATE AS $$ BEGIN RETURN addDays(day,(days * -1)); END; -$$ LANGUAGE plpgsql; \ No newline at end of file +$$ LANGUAGE plpgsql IMMUTABLE; + diff --git a/db/ddlutils/postgresql/functions/charAt.sql b/db/ddlutils/postgresql/functions/charAt.sql index f7e87f111b..ec1a09066a 100644 --- a/db/ddlutils/postgresql/functions/charAt.sql +++ b/db/ddlutils/postgresql/functions/charAt.sql @@ -21,8 +21,6 @@ */ /** Get Character at Position */ -SET search_path = adempiere, pg_catalog; - CREATE OR REPLACE FUNCTION charAt ( IN VARCHAR, -- $1 the string IN INTEGER -- $2 the position @@ -31,4 +29,5 @@ $$ BEGIN RETURN SUBSTR($1, $2, 1); END; -$$ LANGUAGE plpgsql; +$$ LANGUAGE plpgsql IMMUTABLE; + diff --git a/db/ddlutils/postgresql/functions/daysBetween.sql b/db/ddlutils/postgresql/functions/daysBetween.sql index 0ab34ecc52..a9e9caf335 100644 --- a/db/ddlutils/postgresql/functions/daysBetween.sql +++ b/db/ddlutils/postgresql/functions/daysBetween.sql @@ -25,4 +25,5 @@ RETURNS INTEGER AS $$ BEGIN RETURN CAST(p_date1 AS DATE) - CAST(p_date2 as DATE); END; -$$ LANGUAGE plpgsql; +$$ LANGUAGE plpgsql IMMUTABLE; + diff --git a/db/ddlutils/postgresql/functions/documentNo.sql b/db/ddlutils/postgresql/functions/documentNo.sql index 0e3b70038e..ccd5eb3f2d 100644 --- a/db/ddlutils/postgresql/functions/documentNo.sql +++ b/db/ddlutils/postgresql/functions/documentNo.sql @@ -47,4 +47,5 @@ BEGIN RETURN v_DocumentNo; END; $BODY$ - LANGUAGE 'plpgsql' ; + LANGUAGE 'plpgsql' STABLE; + diff --git a/db/ddlutils/postgresql/functions/firstOf.sql b/db/ddlutils/postgresql/functions/firstOf.sql index 3557964f6e..05fa0481c8 100644 --- a/db/ddlutils/postgresql/functions/firstOf.sql +++ b/db/ddlutils/postgresql/functions/firstOf.sql @@ -73,4 +73,5 @@ BEGIN datetime = date_trunc(datepart, $1); RETURN cast(datetime as date) + offsetdays; END; -$$ LANGUAGE plpgsql; +$$ LANGUAGE plpgsql IMMUTABLE; + diff --git a/db/ddlutils/postgresql/functions/get1099bucket.sql b/db/ddlutils/postgresql/functions/get1099bucket.sql index aa108de0fc..4bb2627b83 100644 --- a/db/ddlutils/postgresql/functions/get1099bucket.sql +++ b/db/ddlutils/postgresql/functions/get1099bucket.sql @@ -39,7 +39,6 @@ BEGIN RETURN tmpvar; END; $BODY$ - LANGUAGE plpgsql VOLATILE - COST 100 + LANGUAGE plpgsql STABLE ; diff --git a/db/ddlutils/postgresql/functions/get_Sysconfig.sql b/db/ddlutils/postgresql/functions/get_Sysconfig.sql index e226fd8b79..2043381250 100644 --- a/db/ddlutils/postgresql/functions/get_Sysconfig.sql +++ b/db/ddlutils/postgresql/functions/get_Sysconfig.sql @@ -44,4 +44,5 @@ BEGIN RETURN v_value; END; $BODY$ - LANGUAGE 'plpgsql'; \ No newline at end of file + LANGUAGE 'plpgsql' STABLE; + diff --git a/db/ddlutils/postgresql/functions/nextBusinessDay.sql b/db/ddlutils/postgresql/functions/nextBusinessDay.sql index c6a8a467ee..72af1706d2 100644 --- a/db/ddlutils/postgresql/functions/nextBusinessDay.sql +++ b/db/ddlutils/postgresql/functions/nextBusinessDay.sql @@ -63,4 +63,5 @@ begin return v_nextDate::timestamp with time zone; end; $$ - LANGUAGE plpgsql; + LANGUAGE plpgsql STABLE; + diff --git a/db/ddlutils/postgresql/functions/prodqtyordered.sql b/db/ddlutils/postgresql/functions/prodqtyordered.sql index 2d994d4c04..0663ff3dd1 100644 --- a/db/ddlutils/postgresql/functions/prodqtyordered.sql +++ b/db/ddlutils/postgresql/functions/prodqtyordered.sql @@ -59,5 +59,6 @@ BEGIN RETURN 0; END; $BODY$ - LANGUAGE plpgsql VOLATILE - COST 100; + LANGUAGE plpgsql STABLE +; + diff --git a/db/ddlutils/postgresql/functions/prodqtyreserved.sql b/db/ddlutils/postgresql/functions/prodqtyreserved.sql index 92df6bfc67..242b6a26ee 100644 --- a/db/ddlutils/postgresql/functions/prodqtyreserved.sql +++ b/db/ddlutils/postgresql/functions/prodqtyreserved.sql @@ -59,5 +59,6 @@ BEGIN RETURN 0; END; $BODY$ - LANGUAGE plpgsql VOLATILE - COST 100; + LANGUAGE plpgsql STABLE +; + diff --git a/db/ddlutils/postgresql/functions/round.sql b/db/ddlutils/postgresql/functions/round.sql index 45974819a0..84bda9bf7c 100644 --- a/db/ddlutils/postgresql/functions/round.sql +++ b/db/ddlutils/postgresql/functions/round.sql @@ -6,4 +6,5 @@ $$ BEGIN RETURN ROUND($1, cast($2 as integer)); END; -$$ LANGUAGE plpgsql; +$$ LANGUAGE plpgsql IMMUTABLE; + diff --git a/db/ddlutils/postgresql/functions/trunc.sql b/db/ddlutils/postgresql/functions/trunc.sql index 9771bf7e47..8134292d54 100644 --- a/db/ddlutils/postgresql/functions/trunc.sql +++ b/db/ddlutils/postgresql/functions/trunc.sql @@ -24,7 +24,7 @@ RETURNS TIMESTAMP WITH TIME ZONE AS $$ BEGIN RETURN CAST(datetime AS DATE); END; -$$ LANGUAGE plpgsql; +$$ LANGUAGE plpgsql IMMUTABLE; CREATE OR REPLACE FUNCTION trunc(datetime TIMESTAMP WITH TIME ZONE, format varchar) RETURNS DATE AS $$ @@ -43,11 +43,12 @@ BEGIN RETURN CAST(datetime AS DATE); END IF; END; -$$ LANGUAGE plpgsql; +$$ LANGUAGE plpgsql IMMUTABLE; CREATE OR REPLACE FUNCTION trunc(i INTERVAL) RETURNS INTEGER AS $$ BEGIN RETURN EXTRACT(DAY FROM i); END; -$$ LANGUAGE plpgsql; +$$ LANGUAGE plpgsql IMMUTABLE; + diff --git a/migration/i2.0/oracle/201405221012_Ticket_1003710.sql b/migration/i2.0/oracle/201405221012_Ticket_1003710.sql new file mode 100644 index 0000000000..920d67735d --- /dev/null +++ b/migration/i2.0/oracle/201405221012_Ticket_1003710.sql @@ -0,0 +1,43 @@ +SET SQLBLANKLINES ON +SET DEFINE OFF + +-- May 22, 2014 6:03:29 PM MYT +-- 1003710 Performance issue - Change column reference from table to search +UPDATE AD_Column SET AD_Reference_ID=30,Updated=TO_DATE('2014-05-22 18:03:29','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=55318 +; + +-- May 22, 2014 6:04:22 PM MYT +UPDATE AD_Column SET AD_Reference_ID=30,Updated=TO_DATE('2014-05-22 18:04:22','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=201503 +; + +-- May 22, 2014 6:04:56 PM MYT +UPDATE AD_Column SET AD_Reference_ID=30,Updated=TO_DATE('2014-05-22 18:04:56','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=55303 +; + +-- May 22, 2014 6:06:00 PM MYT +UPDATE AD_Column SET AD_Reference_ID=30,Updated=TO_DATE('2014-05-22 18:06:00','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=56355 +; + +-- May 22, 2014 6:08:12 PM MYT +UPDATE AD_Column SET AD_Reference_ID=30,Updated=TO_DATE('2014-05-22 18:08:12','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=55322 +; + +-- May 22, 2014 6:08:58 PM MYT +UPDATE AD_Column SET AD_Reference_ID=30,Updated=TO_DATE('2014-05-22 18:08:58','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=55323 +; + +-- May 22, 2014 6:09:41 PM MYT +UPDATE AD_Column SET AD_Reference_ID=30,Updated=TO_DATE('2014-05-22 18:09:41','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=52007 +; + +-- May 22, 2014 6:10:08 PM MYT +UPDATE AD_Column SET AD_Reference_ID=30,Updated=TO_DATE('2014-05-22 18:10:08','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=55305 +; + +-- May 22, 2014 6:11:15 PM MYT +UPDATE AD_Column SET AD_Reference_ID=30,Updated=TO_DATE('2014-05-22 18:11:15','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=52008 +; + +SELECT register_migration_script('201405221012_Ticket_1003710.sql') FROM dual +; + diff --git a/migration/i2.0/oracle/201405262306_IDEMPIERE-1967.sql b/migration/i2.0/oracle/201405262306_IDEMPIERE-1967.sql new file mode 100644 index 0000000000..8bc80ae9ab --- /dev/null +++ b/migration/i2.0/oracle/201405262306_IDEMPIERE-1967.sql @@ -0,0 +1,10 @@ +SET SQLBLANKLINES ON +SET DEFINE OFF + +-- May 26, 2014 11:06:10 PM COT +-- IDEMPIERE-1967 Bank transfer process should allow for document number to be optional +UPDATE AD_Process_Para SET IsMandatory='N',Updated=TO_DATE('2014-05-26 22:47:10','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Process_Para_ID=53251 +; + +SELECT register_migration_script('201405262306_IDEMPIERE-1967.sql') FROM dual +; diff --git a/migration/i2.0/postgresql/201405221012_Ticket_1003710.sql b/migration/i2.0/postgresql/201405221012_Ticket_1003710.sql new file mode 100644 index 0000000000..9bc3d5671c --- /dev/null +++ b/migration/i2.0/postgresql/201405221012_Ticket_1003710.sql @@ -0,0 +1,40 @@ +-- May 22, 2014 6:03:29 PM MYT +-- 1003710 Performance issue - Change column reference from table to search +UPDATE AD_Column SET AD_Reference_ID=30,Updated=TO_TIMESTAMP('2014-05-22 18:03:29','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=55318 +; + +-- May 22, 2014 6:04:22 PM MYT +UPDATE AD_Column SET AD_Reference_ID=30,Updated=TO_TIMESTAMP('2014-05-22 18:04:22','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=201503 +; + +-- May 22, 2014 6:04:56 PM MYT +UPDATE AD_Column SET AD_Reference_ID=30,Updated=TO_TIMESTAMP('2014-05-22 18:04:56','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=55303 +; + +-- May 22, 2014 6:06:00 PM MYT +UPDATE AD_Column SET AD_Reference_ID=30,Updated=TO_TIMESTAMP('2014-05-22 18:06:00','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=56355 +; + +-- May 22, 2014 6:08:12 PM MYT +UPDATE AD_Column SET AD_Reference_ID=30,Updated=TO_TIMESTAMP('2014-05-22 18:08:12','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=55322 +; + +-- May 22, 2014 6:08:58 PM MYT +UPDATE AD_Column SET AD_Reference_ID=30,Updated=TO_TIMESTAMP('2014-05-22 18:08:58','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=55323 +; + +-- May 22, 2014 6:09:41 PM MYT +UPDATE AD_Column SET AD_Reference_ID=30,Updated=TO_TIMESTAMP('2014-05-22 18:09:41','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=52007 +; + +-- May 22, 2014 6:10:08 PM MYT +UPDATE AD_Column SET AD_Reference_ID=30,Updated=TO_TIMESTAMP('2014-05-22 18:10:08','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=55305 +; + +-- May 22, 2014 6:11:15 PM MYT +UPDATE AD_Column SET AD_Reference_ID=30,Updated=TO_TIMESTAMP('2014-05-22 18:11:15','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=52008 +; + +SELECT register_migration_script('201405221012_Ticket_1003710.sql') FROM dual +; + diff --git a/migration/i2.0/postgresql/201405262306_IDEMPIERE-1967.sql b/migration/i2.0/postgresql/201405262306_IDEMPIERE-1967.sql new file mode 100644 index 0000000000..3029991ac2 --- /dev/null +++ b/migration/i2.0/postgresql/201405262306_IDEMPIERE-1967.sql @@ -0,0 +1,7 @@ +-- May 26, 2014 11:06:10 PM COT +-- IDEMPIERE-1967 Bank transfer process should allow for document number to be optional +UPDATE AD_Process_Para SET IsMandatory='N',Updated=TO_TIMESTAMP('2014-05-26 22:47:10','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Process_Para_ID=53251 +; + +SELECT register_migration_script('201405262306_IDEMPIERE-1967.sql') FROM dual +; diff --git a/migration/i2.0z/oracle/201405261604_IDEMPIERE-1334.sql b/migration/i2.0z/oracle/201405261604_IDEMPIERE-1334.sql new file mode 100644 index 0000000000..8eeddb55ce --- /dev/null +++ b/migration/i2.0z/oracle/201405261604_IDEMPIERE-1334.sql @@ -0,0 +1,276 @@ +SET SQLBLANKLINES ON +SET DEFINE OFF + +-- May 26, 2014 10:31:26 PM ICT +-- IDEMPIERE-1334 Run one or more processes from Info Window +INSERT INTO AD_Table (ImportTable,CopyColumnsFromTable,IsSecurityEnabled,AccessLevel,LoadSeq,AD_Window_ID,AD_Table_ID,IsHighVolume,IsView,IsChangeLog,EntityType,ReplicationType,AD_Table_UU,IsCentrallyMaintained,IsDeleteable,TableName,Description,Name,IsActive,AD_Org_ID,CreatedBy,Updated,UpdatedBy,Processing,DatabaseViewDrop,AD_Client_ID,Created) VALUES ('N','N','N','4',0,385,200129,'N','N','Y','D','L','399fcb47-f46c-4789-9e45-962cc5379c16','Y','Y','AD_InfoProcess','define process for info window','Info Process','Y',0,100,TO_DATE('2014-05-26 22:31:25','YYYY-MM-DD HH24:MI:SS'),100,'N','N',0,TO_DATE('2014-05-26 22:31:25','YYYY-MM-DD HH24:MI:SS')) +; + +-- May 26, 2014 10:31:27 PM ICT +INSERT INTO AD_Sequence (StartNewYear,CurrentNextSys,IsTableID,CurrentNext,IsAudited,IsAutoSequence,AD_Sequence_ID,Description,Name,IncrementNo,AD_Sequence_UU,AD_Org_ID,CreatedBy,Updated,UpdatedBy,IsActive,StartNo,AD_Client_ID,Created) VALUES ('N',200000,'Y',1000000,'N','Y',200176,'Table AD_InfoProcess','AD_InfoProcess',1,'48700d65-3ba4-4888-8242-6af9a613206a',0,100,TO_DATE('2014-05-26 22:31:26','YYYY-MM-DD HH24:MI:SS'),100,'Y',1000000,0,TO_DATE('2014-05-26 22:31:26','YYYY-MM-DD HH24:MI:SS')) +; + +-- May 26, 2014 10:31:28 PM ICT +INSERT INTO AD_Element (ColumnName,AD_Element_ID,Name,PrintName,AD_Element_UU,AD_Org_ID,CreatedBy,UpdatedBy,IsActive,AD_Client_ID,EntityType,Created,Updated) VALUES ('AD_InfoProcess_ID',202712,'Info Process','Info Process','ebfa3db8-e6b2-43aa-9eaa-e3dc1b2eb7f1',0,100,100,'Y',0,'D',TO_DATE('2014-05-26 22:31:27','YYYY-MM-DD HH24:MI:SS'),TO_DATE('2014-05-26 22:31:27','YYYY-MM-DD HH24:MI:SS')) +; + +-- May 26, 2014 10:31:28 PM ICT +INSERT INTO AD_Column (IsSyncDatabase,Version,AD_Column_ID,IsMandatory,IsTranslated,IsIdentifier,IsParent,FieldLength,IsSelectionColumn,IsKey,IsAutocomplete,IsAllowLogging,AD_Column_UU,IsUpdateable,ColumnName,Name,IsAllowCopy,Updated,CreatedBy,AD_Org_ID,IsActive,Created,UpdatedBy,IsToolbarButton,IsAlwaysUpdateable,AD_Client_ID,EntityType,IsEncrypted,IsSecure,FKConstraintType,AD_Element_ID,AD_Reference_ID,AD_Table_ID) VALUES ('Y',0.0,211241,'Y','N','N','N',10,'N','Y','N','Y','e3154b48-b2ac-4ad2-ba43-92744e8c6a4c','N','AD_InfoProcess_ID','Info Process','N',TO_DATE('2014-05-26 22:31:28','YYYY-MM-DD HH24:MI:SS'),100,0,'Y',TO_DATE('2014-05-26 22:31:28','YYYY-MM-DD HH24:MI:SS'),100,'N','N',0,'D','N','N','N',202712,13,200129) +; + +-- May 26, 2014 10:31:28 PM ICT +CREATE TABLE AD_InfoProcess (AD_InfoProcess_ID NUMBER(10) NOT NULL, CONSTRAINT AD_InfoProcess_Key PRIMARY KEY (AD_InfoProcess_ID)) +; + +-- May 26, 2014 10:31:29 PM ICT +INSERT INTO AD_Element (ColumnName,AD_Element_ID,Name,PrintName,AD_Element_UU,AD_Org_ID,CreatedBy,UpdatedBy,IsActive,AD_Client_ID,EntityType,Created,Updated) VALUES ('AD_InfoProcess_UU',202713,'AD_InfoProcess_UU','AD_InfoProcess_UU','dde8ccd5-449b-4b9b-84a2-720e77eff87b',0,100,100,'Y',0,'D',TO_DATE('2014-05-26 22:31:29','YYYY-MM-DD HH24:MI:SS'),TO_DATE('2014-05-26 22:31:29','YYYY-MM-DD HH24:MI:SS')) +; + +-- May 26, 2014 10:31:30 PM ICT +INSERT INTO AD_Column (IsSyncDatabase,Version,AD_Column_ID,IsMandatory,IsTranslated,IsIdentifier,IsParent,FieldLength,IsSelectionColumn,IsKey,IsAutocomplete,IsAllowLogging,AD_Column_UU,IsUpdateable,ColumnName,Name,IsAllowCopy,Updated,CreatedBy,AD_Org_ID,IsActive,Created,UpdatedBy,IsToolbarButton,IsAlwaysUpdateable,AD_Client_ID,EntityType,IsEncrypted,IsSecure,FKConstraintType,AD_Element_ID,AD_Reference_ID,AD_Table_ID) VALUES ('Y',0.0,211242,'Y','N','N','N',36,'N','N','N','Y','8f961362-5939-48a4-8c8d-8d8b5d86a83e','N','AD_InfoProcess_UU','AD_InfoProcess_UU','N',TO_DATE('2014-05-26 22:31:29','YYYY-MM-DD HH24:MI:SS'),100,0,'Y',TO_DATE('2014-05-26 22:31:29','YYYY-MM-DD HH24:MI:SS'),100,'N','N',0,'D','N','N','N',202713,10,200129) +; + +-- May 26, 2014 10:31:30 PM ICT +ALTER TABLE AD_InfoProcess ADD AD_InfoProcess_UU VARCHAR2(36) NOT NULL +; + +-- May 26, 2014 10:31:30 PM ICT +ALTER TABLE AD_InfoProcess ADD CONSTRAINT AD_InfoProcess_UU_idx UNIQUE (AD_InfoProcess_UU) +; + +-- May 26, 2014 10:31:31 PM ICT +INSERT INTO AD_Column (IsSyncDatabase,Version,AD_Column_ID,IsMandatory,IsTranslated,IsIdentifier,IsParent,FieldLength,IsSelectionColumn,IsKey,IsAutocomplete,IsAllowLogging,AD_Column_UU,IsUpdateable,ColumnName,Description,DefaultValue,Help,Name,IsAllowCopy,Updated,CreatedBy,AD_Org_ID,IsActive,Created,UpdatedBy,IsToolbarButton,IsAlwaysUpdateable,AD_Client_ID,EntityType,IsEncrypted,IsSecure,FKConstraintName,FKConstraintType,AD_Element_ID,AD_Reference_ID,AD_Table_ID,AD_Val_Rule_ID) VALUES ('Y',0.0,211243,'Y','N','N','N',10,'N','N','N','Y','e8fa9743-e852-4fb3-a8ba-aba7190f5d26','N','AD_Client_ID','Client/Tenant for this installation.','@#AD_Client_ID@','A Client is a company or a legal entity. You cannot share data between Clients. Tenant is a synonym for Client.','Client','N',TO_DATE('2014-05-26 22:31:30','YYYY-MM-DD HH24:MI:SS'),100,0,'Y',TO_DATE('2014-05-26 22:31:30','YYYY-MM-DD HH24:MI:SS'),100,'N','N',0,'D','N','N','ADClient_ADInfoProcess','N',102,19,200129,129) +; + +-- May 26, 2014 10:31:31 PM ICT +ALTER TABLE AD_InfoProcess ADD AD_Client_ID NUMBER(10) NOT NULL +; + +-- May 26, 2014 10:31:31 PM ICT +INSERT INTO AD_Column (IsSyncDatabase,Version,AD_Column_ID,IsMandatory,IsTranslated,IsIdentifier,IsParent,FieldLength,IsSelectionColumn,IsKey,IsAutocomplete,IsAllowLogging,AD_Column_UU,IsUpdateable,ColumnName,Description,DefaultValue,Help,Name,IsAllowCopy,Updated,CreatedBy,AD_Org_ID,IsActive,Created,UpdatedBy,IsToolbarButton,IsAlwaysUpdateable,AD_Client_ID,EntityType,IsEncrypted,IsSecure,FKConstraintName,FKConstraintType,AD_Element_ID,AD_Reference_ID,AD_Table_ID,AD_Val_Rule_ID) VALUES ('Y',0.0,211244,'Y','N','N','N',10,'N','N','N','Y','48046a19-4d3c-40e6-93f2-49858061c1ff','N','AD_Org_ID','Organizational entity within client','@#AD_Org_ID@','An organization is a unit of your client or legal entity - examples are store, department. You can share data between organizations.','Organization','N',TO_DATE('2014-05-26 22:31:31','YYYY-MM-DD HH24:MI:SS'),100,0,'Y',TO_DATE('2014-05-26 22:31:31','YYYY-MM-DD HH24:MI:SS'),100,'N','N',0,'D','N','N','ADOrg_ADInfoProcess','N',113,19,200129,104) +; + +-- May 26, 2014 10:31:31 PM ICT +ALTER TABLE AD_InfoProcess ADD AD_Org_ID NUMBER(10) NOT NULL +; + +-- May 26, 2014 10:31:32 PM ICT +INSERT INTO AD_Column (IsSyncDatabase,Version,AD_Column_ID,IsMandatory,IsTranslated,IsIdentifier,IsParent,FieldLength,IsSelectionColumn,IsKey,IsAutocomplete,IsAllowLogging,AD_Column_UU,IsUpdateable,ColumnName,Description,DefaultValue,Help,Name,IsAllowCopy,Updated,CreatedBy,AD_Org_ID,IsActive,Created,UpdatedBy,IsToolbarButton,IsAlwaysUpdateable,AD_Client_ID,EntityType,IsEncrypted,IsSecure,FKConstraintType,AD_Element_ID,AD_Reference_ID,AD_Table_ID) VALUES ('Y',0.0,211245,'Y','N','N','N',1,'N','N','N','Y','0d5a6a7a-b436-4958-814a-18ecafbc8971','Y','IsActive','The record is active in the system','Y','There are two methods of making records unavailable in the system: One is to delete the record, the other is to de-activate the record. A de-activated record is not available for selection, but available for reports. +There are two reasons for de-activating and not deleting records: +(1) The system requires the record for audit purposes. +(2) The record is referenced by other records. E.g., you cannot delete a Business Partner, if there are invoices for this partner record existing. You de-activate the Business Partner and prevent that this record is used for future entries.','Active','N',TO_DATE('2014-05-26 22:31:31','YYYY-MM-DD HH24:MI:SS'),100,0,'Y',TO_DATE('2014-05-26 22:31:31','YYYY-MM-DD HH24:MI:SS'),100,'N','N',0,'D','N','N','N',348,20,200129) +; + +-- May 26, 2014 10:31:32 PM ICT +ALTER TABLE AD_InfoProcess ADD IsActive CHAR(1) DEFAULT 'Y' CHECK (IsActive IN ('Y','N')) NOT NULL +; + +-- May 26, 2014 10:31:33 PM ICT +INSERT INTO AD_Column (IsSyncDatabase,Version,AD_Column_ID,IsMandatory,IsTranslated,IsIdentifier,IsParent,FieldLength,IsSelectionColumn,IsKey,IsAutocomplete,IsAllowLogging,AD_Column_UU,IsUpdateable,ColumnName,Description,DefaultValue,Help,Name,IsAllowCopy,Updated,CreatedBy,AD_Org_ID,IsActive,Created,UpdatedBy,IsToolbarButton,IsAlwaysUpdateable,AD_Client_ID,EntityType,IsEncrypted,IsSecure,FKConstraintType,AD_Element_ID,AD_Reference_ID,AD_Table_ID) VALUES ('Y',0.0,211246,'Y','N','N','N',29,'N','N','N','Y','a8315f0c-3cbd-4092-bcc7-8e1f0bc4021c','N','Created','Date this record was created','SYSDATE','The Created field indicates the date that this record was created.','Created','N',TO_DATE('2014-05-26 22:31:32','YYYY-MM-DD HH24:MI:SS'),100,0,'Y',TO_DATE('2014-05-26 22:31:32','YYYY-MM-DD HH24:MI:SS'),100,'N','N',0,'D','N','N','N',245,16,200129) +; + +-- May 26, 2014 10:31:33 PM ICT +ALTER TABLE AD_InfoProcess ADD Created DATE DEFAULT SYSDATE NOT NULL +; + +-- May 26, 2014 10:31:34 PM ICT +INSERT INTO AD_Column (IsSyncDatabase,Version,AD_Column_ID,IsMandatory,IsTranslated,IsIdentifier,IsParent,FieldLength,IsSelectionColumn,IsKey,IsAutocomplete,IsAllowLogging,AD_Column_UU,IsUpdateable,ColumnName,Description,Help,Name,IsAllowCopy,Updated,CreatedBy,AD_Org_ID,IsActive,Created,UpdatedBy,IsToolbarButton,IsAlwaysUpdateable,AD_Client_ID,EntityType,IsEncrypted,IsSecure,FKConstraintType,AD_Element_ID,AD_Reference_ID,AD_Reference_Value_ID,AD_Table_ID) VALUES ('Y',0.0,211247,'Y','N','N','N',10,'N','N','N','Y','f2e43604-537c-46a7-a08a-425589a290de','N','CreatedBy','User who created this records','The Created By field indicates the user who created this record.','Created By','N',TO_DATE('2014-05-26 22:31:33','YYYY-MM-DD HH24:MI:SS'),100,0,'Y',TO_DATE('2014-05-26 22:31:33','YYYY-MM-DD HH24:MI:SS'),100,'N','N',0,'D','N','N','N',246,18,110,200129) +; + +-- May 26, 2014 10:31:34 PM ICT +ALTER TABLE AD_InfoProcess ADD CreatedBy NUMBER(10) NOT NULL +; + +-- May 26, 2014 10:31:35 PM ICT +INSERT INTO AD_Column (IsSyncDatabase,Version,AD_Column_ID,IsMandatory,IsTranslated,IsIdentifier,IsParent,FieldLength,IsSelectionColumn,IsKey,IsAutocomplete,IsAllowLogging,AD_Column_UU,IsUpdateable,ColumnName,Description,DefaultValue,Help,Name,IsAllowCopy,Updated,CreatedBy,AD_Org_ID,IsActive,Created,UpdatedBy,IsToolbarButton,IsAlwaysUpdateable,AD_Client_ID,EntityType,IsEncrypted,IsSecure,FKConstraintType,AD_Element_ID,AD_Reference_ID,AD_Table_ID) VALUES ('Y',0.0,211248,'Y','N','N','N',29,'N','N','N','Y','87143907-1038-4c5d-90f6-3114a6fc7edf','N','Updated','Date this record was updated','SYSDATE','The Updated field indicates the date that this record was updated.','Updated','N',TO_DATE('2014-05-26 22:31:34','YYYY-MM-DD HH24:MI:SS'),100,0,'Y',TO_DATE('2014-05-26 22:31:34','YYYY-MM-DD HH24:MI:SS'),100,'N','N',0,'D','N','N','N',607,16,200129) +; + +-- May 26, 2014 10:31:35 PM ICT +ALTER TABLE AD_InfoProcess ADD Updated DATE DEFAULT SYSDATE NOT NULL +; + +-- May 26, 2014 10:31:35 PM ICT +INSERT INTO AD_Column (IsSyncDatabase,Version,AD_Column_ID,IsMandatory,IsTranslated,IsIdentifier,IsParent,FieldLength,IsSelectionColumn,IsKey,IsAutocomplete,IsAllowLogging,AD_Column_UU,IsUpdateable,ColumnName,Description,Help,Name,IsAllowCopy,Updated,CreatedBy,AD_Org_ID,IsActive,Created,UpdatedBy,IsToolbarButton,IsAlwaysUpdateable,AD_Client_ID,EntityType,IsEncrypted,IsSecure,FKConstraintType,AD_Element_ID,AD_Reference_ID,AD_Reference_Value_ID,AD_Table_ID) VALUES ('Y',0.0,211249,'Y','N','N','N',10,'N','N','N','Y','197f9f68-6340-45a8-9d75-9d027f8bcc75','N','UpdatedBy','User who updated this records','The Updated By field indicates the user who updated this record.','Updated By','N',TO_DATE('2014-05-26 22:31:35','YYYY-MM-DD HH24:MI:SS'),100,0,'Y',TO_DATE('2014-05-26 22:31:35','YYYY-MM-DD HH24:MI:SS'),100,'N','N',0,'D','N','N','N',608,18,110,200129) +; + +-- May 26, 2014 10:31:35 PM ICT +ALTER TABLE AD_InfoProcess ADD UpdatedBy NUMBER(10) NOT NULL +; + +-- May 26, 2014 10:31:36 PM ICT +INSERT INTO AD_Column (IsSyncDatabase,Version,AD_Column_ID,IsMandatory,IsTranslated,IsIdentifier,IsParent,FieldLength,IsSelectionColumn,IsKey,IsAutocomplete,IsAllowLogging,AD_Column_UU,IsUpdateable,ColumnName,Description,Help,Name,IsAllowCopy,Updated,CreatedBy,AD_Org_ID,IsActive,Created,UpdatedBy,IsToolbarButton,IsAlwaysUpdateable,AD_Client_ID,EntityType,IsEncrypted,IsSecure,FKConstraintType,AD_Element_ID,AD_Reference_ID,AD_Table_ID) VALUES ('Y',0.0,211250,'Y','N','Y','N',60,'Y','N','N','Y','cba0a7f1-a35e-4410-b53d-b47a0a81b8d5','Y','Name','Alphanumeric identifier of the entity','The name of an entity (record) is used as an default search option in addition to the search key. The name is up to 60 characters in length.','Name','Y',TO_DATE('2014-05-26 22:31:35','YYYY-MM-DD HH24:MI:SS'),100,0,'Y',TO_DATE('2014-05-26 22:31:35','YYYY-MM-DD HH24:MI:SS'),100,'N','N',0,'D','N','N','N',469,10,200129) +; + +-- May 26, 2014 10:31:36 PM ICT +ALTER TABLE AD_InfoProcess ADD Name VARCHAR2(60) NOT NULL +; + +-- May 26, 2014 10:31:37 PM ICT +INSERT INTO AD_Column (IsSyncDatabase,Version,AD_Column_ID,IsMandatory,IsTranslated,IsIdentifier,IsParent,FieldLength,IsSelectionColumn,IsKey,IsAutocomplete,IsAllowLogging,AD_Column_UU,IsUpdateable,ColumnName,Description,Help,Name,IsAllowCopy,Updated,CreatedBy,AD_Org_ID,IsActive,Created,UpdatedBy,IsToolbarButton,IsAlwaysUpdateable,AD_Client_ID,EntityType,IsEncrypted,IsSecure,FKConstraintType,AD_Element_ID,AD_Reference_ID,AD_Table_ID) VALUES ('Y',0.0,211251,'N','N','N','N',255,'Y','N','N','Y','da7faea4-1447-4912-975d-9916325f892c','Y','Description','Optional short description of the record','A description is limited to 255 characters.','Description','Y',TO_DATE('2014-05-26 22:31:36','YYYY-MM-DD HH24:MI:SS'),100,0,'Y',TO_DATE('2014-05-26 22:31:36','YYYY-MM-DD HH24:MI:SS'),100,'N','N',0,'D','N','N','N',275,10,200129) +; + +-- May 26, 2014 10:31:37 PM ICT +ALTER TABLE AD_InfoProcess ADD Description VARCHAR2(255) DEFAULT NULL +; + +-- May 26, 2014 10:31:38 PM ICT +INSERT INTO AD_Column (IsSyncDatabase,Version,AD_Column_ID,IsMandatory,IsTranslated,IsIdentifier,IsParent,FieldLength,IsSelectionColumn,IsKey,IsAutocomplete,IsAllowLogging,AD_Column_UU,IsUpdateable,ColumnName,Description,Help,Name,IsAllowCopy,Updated,CreatedBy,AD_Org_ID,IsActive,Created,UpdatedBy,IsToolbarButton,IsAlwaysUpdateable,AD_Client_ID,EntityType,IsEncrypted,IsSecure,FKConstraintType,AD_Element_ID,AD_Reference_ID,AD_Table_ID) VALUES ('Y',0.0,211252,'N','N','N','N',120,'N','N','N','Y','54fdf7c3-564a-48ea-af3c-314efca2f0ed','Y','ImageURL','URL of image','URL of image; The image is not stored in the database, but retrieved at runtime. The image can be a gif, jpeg or png.','Image URL','Y',TO_DATE('2014-05-26 22:31:37','YYYY-MM-DD HH24:MI:SS'),100,0,'Y',TO_DATE('2014-05-26 22:31:37','YYYY-MM-DD HH24:MI:SS'),100,'N','N',0,'D','N','N','N',1720,10,200129) +; + +-- May 26, 2014 10:31:38 PM ICT +ALTER TABLE AD_InfoProcess ADD ImageURL VARCHAR2(120) DEFAULT NULL +; + +-- May 26, 2014 10:31:38 PM ICT +INSERT INTO AD_Column (IsSyncDatabase,Version,AD_Column_ID,IsMandatory,IsTranslated,IsIdentifier,IsParent,FieldLength,IsSelectionColumn,IsKey,IsAutocomplete,IsAllowLogging,AD_Column_UU,IsUpdateable,ColumnName,Description,DefaultValue,Help,Name,IsAllowCopy,Updated,CreatedBy,AD_Org_ID,IsActive,Created,UpdatedBy,IsToolbarButton,IsAlwaysUpdateable,AD_Client_ID,EntityType,IsEncrypted,IsSecure,FKConstraintType,AD_Element_ID,AD_Reference_ID,AD_Table_ID) VALUES ('Y',0.0,211253,'Y','N','N','N',10,'N','N','N','Y','b9449134-fe06-4a9a-b1a6-54077974de21','Y','SeqNo','Method of ordering records; lowest number comes first','@SQL=SELECT NVL(MAX(SeqNo),0)+10 AS DefaultValue FROM AD_InfoProcess WHERE AD_InfoWindow_ID=@AD_InfoWindow_ID@','The Sequence indicates the order of records','Sequence','N',TO_DATE('2014-05-26 22:31:38','YYYY-MM-DD HH24:MI:SS'),100,0,'Y',TO_DATE('2014-05-26 22:31:38','YYYY-MM-DD HH24:MI:SS'),100,'N','N',0,'D','N','N','N',566,11,200129) +; + +-- May 26, 2014 10:31:38 PM ICT +ALTER TABLE AD_InfoProcess ADD SeqNo NUMBER(10) NOT NULL +; + +-- May 26, 2014 10:31:39 PM ICT +INSERT INTO AD_Column (IsSyncDatabase,Version,AD_Column_ID,IsMandatory,IsTranslated,IsIdentifier,IsParent,FieldLength,IsSelectionColumn,IsKey,IsAutocomplete,IsAllowLogging,AD_Column_UU,IsUpdateable,ColumnName,Description,Help,Name,IsAllowCopy,Updated,CreatedBy,AD_Org_ID,IsActive,Created,UpdatedBy,IsToolbarButton,IsAlwaysUpdateable,AD_Client_ID,EntityType,IsEncrypted,IsSecure,FKConstraintName,FKConstraintType,AD_Element_ID,AD_Reference_ID,AD_Table_ID) VALUES ('Y',0.0,211254,'Y','N','N','N',10,'N','N','N','Y','be4dc8ea-58bf-4238-bff2-71099c2f36f9','Y','AD_Process_ID','Process or Report','The Process field identifies a unique Process or Report in the system.','Process','Y',TO_DATE('2014-05-26 22:31:38','YYYY-MM-DD HH24:MI:SS'),100,0,'Y',TO_DATE('2014-05-26 22:31:38','YYYY-MM-DD HH24:MI:SS'),100,'N','N',0,'D','N','N','ADProcess_ADInfoProcess','N',117,19,200129) +; + +-- May 26, 2014 10:31:39 PM ICT +ALTER TABLE AD_InfoProcess ADD AD_Process_ID NUMBER(10) NOT NULL +; + +-- May 26, 2014 10:31:40 PM ICT +INSERT INTO AD_Column (IsSyncDatabase,Version,AD_Column_ID,IsMandatory,IsTranslated,IsIdentifier,IsParent,FieldLength,IsSelectionColumn,IsKey,IsAutocomplete,IsAllowLogging,AD_Column_UU,IsUpdateable,ColumnName,Description,Help,Name,IsAllowCopy,Updated,CreatedBy,AD_Org_ID,IsActive,Created,UpdatedBy,IsToolbarButton,IsAlwaysUpdateable,AD_Client_ID,EntityType,IsEncrypted,IsSecure,FKConstraintName,FKConstraintType,AD_Element_ID,AD_Reference_ID,AD_Table_ID) VALUES ('Y',0.0,211255,'N','N','N','Y',10,'N','N','N','Y','d9a775c3-dd5c-4e91-8416-60b78c33eb4e','N','AD_InfoWindow_ID','Info and search/select Window','The Info window is used to search and select records as well as display information relevant to the selection.','Info Window','Y',TO_DATE('2014-05-26 22:31:39','YYYY-MM-DD HH24:MI:SS'),100,0,'Y',TO_DATE('2014-05-26 22:31:39','YYYY-MM-DD HH24:MI:SS'),100,'N','N',0,'D','N','N','ADInfoWindow_ADInfoProcess','C',3068,19,200129) +; + +-- May 26, 2014 10:31:40 PM ICT +ALTER TABLE AD_InfoProcess ADD AD_InfoWindow_ID NUMBER(10) DEFAULT NULL +; + +-- May 26, 2014 10:31:41 PM ICT +INSERT INTO AD_Column (SeqNoSelection,IsSyncDatabase,Version,AD_Column_ID,IsMandatory,IsTranslated,IsIdentifier,SeqNo,IsParent,FieldLength,IsSelectionColumn,IsKey,IsAutocomplete,IsAllowLogging,AD_Column_UU,IsUpdateable,ColumnName,Description,Help,Name,IsAllowCopy,Updated,CreatedBy,AD_Org_ID,IsActive,Created,UpdatedBy,IsToolbarButton,IsAlwaysUpdateable,AD_Client_ID,EntityType,IsEncrypted,IsSecure,FKConstraintType,AD_Element_ID,AD_Reference_ID,AD_Table_ID) VALUES (0,'Y',0,211256,'N','N','N',0,'N',2000,'N','N','N','Y','54387a92-4caa-4ab2-a765-51cf779a537c','Y','Help','Comment or Hint','The Help field contains a hint, comment or help about the use of this item.','Comment/Help','Y',TO_DATE('2014-05-26 22:31:40','YYYY-MM-DD HH24:MI:SS'),100,0,'Y',TO_DATE('2014-05-26 22:31:40','YYYY-MM-DD HH24:MI:SS'),100,'N','N',0,'D','N','N','N',326,14,200129) +; + +-- May 26, 2014 10:31:41 PM ICT +ALTER TABLE AD_InfoProcess ADD Help VARCHAR2(2000) DEFAULT NULL +; + +-- May 26, 2014 10:31:41 PM ICT +INSERT INTO AD_Element (ColumnName,AD_Element_ID,Help,Name,Description,PrintName,AD_Element_UU,AD_Org_ID,CreatedBy,UpdatedBy,IsActive,AD_Client_ID,EntityType,Created,Updated) VALUES ('LayoutType',202714,'Process info can display as button, list, menu','LayoutType','Layout type of info process','Layout Type','913eafda-0cdc-4c44-85f8-487d77a3787c',0,100,100,'Y',0,'D',TO_DATE('2014-05-26 22:31:41','YYYY-MM-DD HH24:MI:SS'),TO_DATE('2014-05-26 22:31:41','YYYY-MM-DD HH24:MI:SS')) +; + +-- May 26, 2014 10:31:42 PM ICT +INSERT INTO AD_Reference (AD_Reference_ID,Name,EntityType,AD_Reference_UU,IsOrderByValue,Description,ValidationType,AD_Org_ID,CreatedBy,Updated,IsActive,Created,UpdatedBy,AD_Client_ID) VALUES (200083,'AD_InfoProcess LayoutType','D','2171ebd2-e11a-4612-9885-128f155d65e8','N','Define layout type of info process button','L',0,100,TO_DATE('2014-05-26 22:31:42','YYYY-MM-DD HH24:MI:SS'),'Y',TO_DATE('2014-05-26 22:31:42','YYYY-MM-DD HH24:MI:SS'),100,0) +; + +-- May 26, 2014 10:31:43 PM ICT +INSERT INTO AD_Ref_List (AD_Ref_List_ID,AD_Reference_ID,Description,Name,AD_Ref_List_UU,Value,Created,CreatedBy,Updated,UpdatedBy,IsActive,EntityType,AD_Client_ID,AD_Org_ID) VALUES (200185,200083,'Display as button','Button','6884dcd1-bc9a-4d16-9b2c-fe40968747f8','B',TO_DATE('2014-05-26 22:31:42','YYYY-MM-DD HH24:MI:SS'),100,TO_DATE('2014-05-26 22:31:42','YYYY-MM-DD HH24:MI:SS'),100,'Y','D',0,0) +; + +-- May 26, 2014 10:31:44 PM ICT +INSERT INTO AD_Ref_List (AD_Ref_List_ID,AD_Reference_ID,Description,Name,AD_Ref_List_UU,Value,Created,CreatedBy,Updated,UpdatedBy,IsActive,EntityType,AD_Client_ID,AD_Org_ID) VALUES (200186,200083,'Display as menu on a gear button','Menu','7b539591-296a-43ee-916c-c87c35acc84d','M',TO_DATE('2014-05-26 22:31:43','YYYY-MM-DD HH24:MI:SS'),100,TO_DATE('2014-05-26 22:31:43','YYYY-MM-DD HH24:MI:SS'),100,'Y','D',0,0) +; + +-- May 26, 2014 10:31:44 PM ICT +INSERT INTO AD_Ref_List (AD_Ref_List_ID,AD_Reference_ID,Description,Name,AD_Ref_List_UU,Value,Created,CreatedBy,Updated,UpdatedBy,IsActive,EntityType,AD_Client_ID,AD_Org_ID) VALUES (200187,200083,'Display as list','List','ff0cba3e-e82c-4aa8-9f9b-bedf681b822d','L',TO_DATE('2014-05-26 22:31:44','YYYY-MM-DD HH24:MI:SS'),100,TO_DATE('2014-05-26 22:31:44','YYYY-MM-DD HH24:MI:SS'),100,'Y','D',0,0) +; + +-- May 26, 2014 10:31:45 PM ICT +INSERT INTO AD_Column (SeqNoSelection,IsSyncDatabase,Version,AD_Column_ID,IsMandatory,IsTranslated,IsIdentifier,SeqNo,IsParent,FieldLength,IsSelectionColumn,IsKey,IsAutocomplete,IsAllowLogging,AD_Column_UU,IsUpdateable,ColumnName,Description,Help,Name,IsAllowCopy,Updated,CreatedBy,AD_Org_ID,IsActive,Created,UpdatedBy,IsToolbarButton,IsAlwaysUpdateable,AD_Client_ID,EntityType,IsEncrypted,IsSecure,FKConstraintType,AD_Element_ID,AD_Reference_ID,AD_Reference_Value_ID,AD_Table_ID) VALUES (0,'Y',0,211257,'N','N','N',0,'N',1,'N','N','N','Y','a0e8f5b5-ac5f-44ba-a2c9-060dd3231c4e','Y','LayoutType','Layout type of info process','Process info can display as button, list, menu','LayoutType','Y',TO_DATE('2014-05-26 22:31:45','YYYY-MM-DD HH24:MI:SS'),100,0,'Y',TO_DATE('2014-05-26 22:31:45','YYYY-MM-DD HH24:MI:SS'),100,'N','N',0,'D','N','N','N',202714,17,200083,200129) +; + +-- May 26, 2014 10:31:45 PM ICT +ALTER TABLE AD_InfoProcess ADD LayoutType VARCHAR2(1) DEFAULT NULL +; + +-- 28/05/2014 01:24:40 PM COT +UPDATE AD_Column SET IsMandatory='Y', DefaultValue='B',Updated=TO_DATE('2014-05-28 13:24:40','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=211257 +; + +-- 28/05/2014 01:24:44 PM COT +ALTER TABLE AD_InfoProcess MODIFY LayoutType VARCHAR2(10) DEFAULT 'B' +; + +-- 28/05/2014 01:24:44 PM COT +ALTER TABLE AD_InfoProcess MODIFY LayoutType NOT NULL +; + +-- May 26, 2014 10:31:48 PM ICT +INSERT INTO AD_Tab (ImportFields,Processing,IsSingleRow,AD_Window_ID,SeqNo,IsTranslationTab,IsSortTab,HasTree,IsInfoTab,IsReadOnly,IsInsertRecord,IsAdvancedTab,TabLevel,AD_Tab_UU,EntityType,Name,AD_Tab_ID,AD_Org_ID,Created,CreatedBy,Updated,UpdatedBy,IsActive,AD_Table_ID,AD_Client_ID,TreeDisplayedOn) VALUES ('N','N','Y',385,60,'N','N','N','N','N','Y','N',1,'2a39f93a-2062-404a-8e28-19fc45982162','D','Process',200142,0,TO_DATE('2014-05-26 22:31:47','YYYY-MM-DD HH24:MI:SS'),100,TO_DATE('2014-05-26 22:31:47','YYYY-MM-DD HH24:MI:SS'),100,'Y',200129,0,'B') +; + +-- May 26, 2014 10:31:49 PM ICT +INSERT INTO AD_Field (IsEncrypted,AD_Tab_ID,DisplayLength,IsSameLine,IsHeading,SeqNo,IsCentrallyMaintained,AD_Field_ID,IsReadOnly,Name,AD_Field_UU,IsDisplayed,IsFieldOnly,UpdatedBy,AD_Org_ID,CreatedBy,Updated,IsActive,IsDisplayedGrid,XPosition,IsQuickEntry,AD_Client_ID,ColumnSpan,NumLines,IsAdvancedField,IsDefaultFocus,AD_Column_ID,EntityType,Created) VALUES ('N',200142,36,'N','N',0,'Y',203026,'N','AD_InfoProcess_UU','87361dd1-cfc0-412d-a344-e5f602650e32','N','N',100,0,100,TO_DATE('2014-05-26 22:31:48','YYYY-MM-DD HH24:MI:SS'),'Y','N',1,'N',0,2,1,'N','N',211242,'D',TO_DATE('2014-05-26 22:31:48','YYYY-MM-DD HH24:MI:SS')) +; + +-- May 26, 2014 10:31:49 PM ICT +INSERT INTO AD_Field (IsEncrypted,AD_Tab_ID,DisplayLength,IsSameLine,IsHeading,SeqNo,IsCentrallyMaintained,AD_Field_ID,IsReadOnly,Name,AD_Field_UU,IsDisplayed,IsFieldOnly,UpdatedBy,AD_Org_ID,CreatedBy,Updated,IsActive,IsDisplayedGrid,XPosition,IsQuickEntry,AD_Client_ID,ColumnSpan,NumLines,IsAdvancedField,IsDefaultFocus,AD_Column_ID,EntityType,Created) VALUES ('N',200142,10,'N','N',0,'Y',203027,'N','Info Process','8020c77c-816a-4be9-a38c-747aed3afcf2','N','N',100,0,100,TO_DATE('2014-05-26 22:31:49','YYYY-MM-DD HH24:MI:SS'),'Y','N',1,'N',0,2,1,'N','N',211241,'D',TO_DATE('2014-05-26 22:31:49','YYYY-MM-DD HH24:MI:SS')) +; + +-- May 26, 2014 10:31:50 PM ICT +INSERT INTO AD_Field (IsEncrypted,AD_Tab_ID,DisplayLength,IsSameLine,IsHeading,SeqNo,IsCentrallyMaintained,AD_Field_ID,IsReadOnly,Help,Description,Name,AD_Field_UU,IsDisplayed,IsFieldOnly,UpdatedBy,AD_Org_ID,CreatedBy,Updated,IsActive,IsDisplayedGrid,XPosition,IsQuickEntry,AD_Client_ID,ColumnSpan,NumLines,IsAdvancedField,IsDefaultFocus,AD_Column_ID,EntityType,Created) VALUES ('N',200142,10,'N','N',10,'Y',203028,'Y','A Client is a company or a legal entity. You cannot share data between Clients. Tenant is a synonym for Client.','Client/Tenant for this installation.','Client','a6fccb4a-2521-4369-a1bb-06602ae9c840','Y','N',100,0,100,TO_DATE('2014-05-26 22:31:49','YYYY-MM-DD HH24:MI:SS'),'Y','N',1,'N',0,2,1,'N','N',211243,'D',TO_DATE('2014-05-26 22:31:49','YYYY-MM-DD HH24:MI:SS')) +; + +-- May 26, 2014 10:31:51 PM ICT +INSERT INTO AD_Field (IsEncrypted,AD_Tab_ID,DisplayLength,IsSameLine,IsHeading,SeqNo,IsCentrallyMaintained,AD_Field_ID,IsReadOnly,Help,Description,Name,AD_Field_UU,IsDisplayed,IsFieldOnly,IsAllowCopy,UpdatedBy,AD_Org_ID,CreatedBy,Updated,IsActive,IsDisplayedGrid,XPosition,IsQuickEntry,AD_Client_ID,ColumnSpan,NumLines,IsAdvancedField,IsDefaultFocus,AD_Column_ID,EntityType,Created) VALUES ('N',200142,10,'N','N',20,'Y',203029,'Y','An organization is a unit of your client or legal entity - examples are store, department. You can share data between organizations.','Organizational entity within client','Organization','60f9d173-cefb-417c-8080-8bb16aebff7e','Y','N','Y',100,0,100,TO_DATE('2014-05-26 22:31:50','YYYY-MM-DD HH24:MI:SS'),'Y','N',4,'N',0,2,1,'N','N',211244,'D',TO_DATE('2014-05-26 22:31:50','YYYY-MM-DD HH24:MI:SS')) +; + +-- May 26, 2014 10:31:51 PM ICT +INSERT INTO AD_Field (IsEncrypted,AD_Tab_ID,DisplayLength,IsSameLine,IsHeading,SeqNo,IsCentrallyMaintained,AD_Field_ID,IsReadOnly,Help,Description,Name,AD_Field_UU,IsDisplayed,IsFieldOnly,UpdatedBy,AD_Org_ID,CreatedBy,Updated,IsActive,IsDisplayedGrid,SeqNoGrid,XPosition,IsQuickEntry,AD_Client_ID,ColumnSpan,NumLines,IsAdvancedField,IsDefaultFocus,AD_Column_ID,EntityType,Created) VALUES ('N',200142,10,'N','N',30,'Y',203030,'Y','The Info window is used to search and select records as well as display information relevant to the selection.','Info and search/select Window','Info Window','ecc17f1a-a61e-4449-a35b-9915088cad60','Y','N',100,0,100,TO_DATE('2014-05-26 22:31:51','YYYY-MM-DD HH24:MI:SS'),'Y','Y',60,1,'N',0,2,1,'N','N',211255,'D',TO_DATE('2014-05-26 22:31:51','YYYY-MM-DD HH24:MI:SS')) +; + +-- May 26, 2014 10:31:52 PM ICT +INSERT INTO AD_Field (IsEncrypted,AD_Tab_ID,DisplayLength,IsSameLine,IsHeading,SeqNo,IsCentrallyMaintained,AD_Field_ID,IsReadOnly,Help,Description,Name,AD_Field_UU,IsDisplayed,IsFieldOnly,UpdatedBy,AD_Org_ID,CreatedBy,Updated,IsActive,IsDisplayedGrid,SeqNoGrid,XPosition,IsQuickEntry,AD_Client_ID,ColumnSpan,NumLines,IsAdvancedField,IsDefaultFocus,AD_Column_ID,EntityType,Created) VALUES ('N',200142,120,'N','N',40,'Y',203031,'N','URL of image; The image is not stored in the database, but retrieved at runtime. The image can be a gif, jpeg or png.','URL of image','Image URL','8a9c636e-677b-464c-a942-3e0e8f5ad3a4','Y','N',100,0,100,TO_DATE('2014-05-26 22:31:51','YYYY-MM-DD HH24:MI:SS'),'Y','Y',30,4,'N',0,2,1,'N','N',211252,'D',TO_DATE('2014-05-26 22:31:51','YYYY-MM-DD HH24:MI:SS')) +; + +-- May 26, 2014 10:31:53 PM ICT +INSERT INTO AD_Field (IsEncrypted,AD_Tab_ID,DisplayLength,IsSameLine,IsHeading,SeqNo,IsCentrallyMaintained,AD_Field_ID,IsReadOnly,Help,Description,Name,AD_Field_UU,IsDisplayed,IsFieldOnly,UpdatedBy,AD_Org_ID,CreatedBy,Updated,IsActive,IsDisplayedGrid,SeqNoGrid,XPosition,IsQuickEntry,AD_Client_ID,ColumnSpan,NumLines,IsAdvancedField,IsDefaultFocus,AD_Column_ID,EntityType,Created) VALUES ('N',200142,60,'N','N',50,'Y',203032,'N','The name of an entity (record) is used as an default search option in addition to the search key. The name is up to 60 characters in length.','Alphanumeric identifier of the entity','Name','af4c42ad-5b90-474a-80f4-41341a08d3cf','Y','N',100,0,100,TO_DATE('2014-05-26 22:31:52','YYYY-MM-DD HH24:MI:SS'),'Y','Y',10,1,'N',0,5,1,'N','N',211250,'D',TO_DATE('2014-05-26 22:31:52','YYYY-MM-DD HH24:MI:SS')) +; + +-- May 26, 2014 10:31:53 PM ICT +INSERT INTO AD_Field (IsEncrypted,AD_Tab_ID,DisplayLength,IsSameLine,IsHeading,SeqNo,IsCentrallyMaintained,AD_Field_ID,IsReadOnly,Help,Description,Name,AD_Field_UU,IsDisplayed,IsFieldOnly,UpdatedBy,AD_Org_ID,CreatedBy,Updated,IsActive,IsDisplayedGrid,SeqNoGrid,XPosition,IsQuickEntry,AD_Client_ID,ColumnSpan,NumLines,IsAdvancedField,IsDefaultFocus,AD_Column_ID,EntityType,Created) VALUES ('N',200142,255,'N','N',60,'Y',203033,'N','A description is limited to 255 characters.','Optional short description of the record','Description','cc49a78e-2927-484e-990e-8c303be44b4c','Y','N',100,0,100,TO_DATE('2014-05-26 22:31:53','YYYY-MM-DD HH24:MI:SS'),'Y','Y',20,1,'N',0,5,1,'N','N',211251,'D',TO_DATE('2014-05-26 22:31:53','YYYY-MM-DD HH24:MI:SS')) +; + +-- May 26, 2014 10:31:54 PM ICT +INSERT INTO AD_Field (SortNo,IsEncrypted,AD_Tab_ID,DisplayLength,IsSameLine,IsHeading,SeqNo,IsCentrallyMaintained,AD_Field_ID,IsReadOnly,Help,Description,Name,AD_Field_UU,IsDisplayed,IsFieldOnly,UpdatedBy,AD_Org_ID,CreatedBy,Updated,IsActive,IsDisplayedGrid,SeqNoGrid,XPosition,IsQuickEntry,AD_Client_ID,ColumnSpan,NumLines,IsAdvancedField,IsDefaultFocus,AD_Column_ID,EntityType,Created) VALUES (0,'N',200142,0,'N','N',70,'Y',203034,'N','The Help field contains a hint, comment or help about the use of this item.','Comment or Hint','Comment/Help','4b9118d1-4cc9-47fe-beee-b24e4d1263cb','Y','N',100,0,100,TO_DATE('2014-05-26 22:31:53','YYYY-MM-DD HH24:MI:SS'),'Y','Y',80,1,'N',0,5,3,'N','N',211256,'D',TO_DATE('2014-05-26 22:31:53','YYYY-MM-DD HH24:MI:SS')) +; + +-- May 26, 2014 10:31:55 PM ICT +INSERT INTO AD_Field (IsEncrypted,AD_Tab_ID,DisplayLength,IsSameLine,IsHeading,SeqNo,IsCentrallyMaintained,AD_Field_ID,IsReadOnly,Help,Description,Name,AD_Field_UU,IsDisplayed,IsFieldOnly,UpdatedBy,AD_Org_ID,CreatedBy,Updated,IsActive,IsDisplayedGrid,SeqNoGrid,XPosition,IsQuickEntry,AD_Client_ID,ColumnSpan,NumLines,IsAdvancedField,IsDefaultFocus,AD_Column_ID,EntityType,Created) VALUES ('N',200142,10,'N','N',80,'Y',203035,'N','The Process field identifies a unique Process or Report in the system.','Process or Report','Process','2f7cb5e4-1af9-4912-b9dd-bbc8ccbae537','Y','N',100,0,100,TO_DATE('2014-05-26 22:31:54','YYYY-MM-DD HH24:MI:SS'),'Y','Y',50,1,'N',0,2,1,'N','N',211254,'D',TO_DATE('2014-05-26 22:31:54','YYYY-MM-DD HH24:MI:SS')) +; + +-- May 26, 2014 10:31:55 PM ICT +INSERT INTO AD_Field (IsEncrypted,AD_Tab_ID,DisplayLength,IsSameLine,IsHeading,SeqNo,IsCentrallyMaintained,AD_Field_ID,IsReadOnly,Help,Description,Name,AD_Field_UU,IsDisplayed,IsFieldOnly,UpdatedBy,AD_Org_ID,CreatedBy,Updated,IsActive,IsDisplayedGrid,SeqNoGrid,XPosition,IsQuickEntry,AD_Client_ID,ColumnSpan,NumLines,IsAdvancedField,IsDefaultFocus,AD_Column_ID,EntityType,Created) VALUES ('N',200142,10,'N','N',90,'Y',203036,'N','The Sequence indicates the order of records','Method of ordering records; lowest number comes first','Sequence','c5ee4976-735e-40f8-8cd4-4bacc36adcdf','Y','N',100,0,100,TO_DATE('2014-05-26 22:31:55','YYYY-MM-DD HH24:MI:SS'),'Y','Y',40,4,'N',0,2,1,'N','N',211253,'D',TO_DATE('2014-05-26 22:31:55','YYYY-MM-DD HH24:MI:SS')) +; + +-- May 26, 2014 10:31:56 PM ICT +INSERT INTO AD_Field (SortNo,IsEncrypted,AD_Tab_ID,DisplayLength,IsSameLine,IsHeading,SeqNo,IsCentrallyMaintained,AD_Field_ID,IsReadOnly,Help,Description,Name,AD_Field_UU,IsDisplayed,IsFieldOnly,UpdatedBy,AD_Org_ID,CreatedBy,Updated,IsActive,IsDisplayedGrid,SeqNoGrid,XPosition,IsQuickEntry,AD_Client_ID,ColumnSpan,NumLines,IsAdvancedField,IsDefaultFocus,AD_Column_ID,EntityType,Created) VALUES (0,'N',200142,0,'N','N',100,'Y',203037,'N','Process info can display as button, list, menu','Layout type of info process','LayoutType','106b208d-b39b-4ab0-b839-7d0c95951bea','Y','N',100,0,100,TO_DATE('2014-05-26 22:31:55','YYYY-MM-DD HH24:MI:SS'),'Y','Y',90,1,'N',0,2,1,'N','N',211257,'D',TO_DATE('2014-05-26 22:31:55','YYYY-MM-DD HH24:MI:SS')) +; + +-- May 26, 2014 10:31:57 PM ICT +INSERT INTO AD_Field (IsEncrypted,AD_Tab_ID,DisplayLength,IsSameLine,IsHeading,SeqNo,IsCentrallyMaintained,AD_Field_ID,IsReadOnly,Help,Description,Name,AD_Field_UU,IsDisplayed,IsFieldOnly,UpdatedBy,AD_Org_ID,CreatedBy,Updated,IsActive,IsDisplayedGrid,SeqNoGrid,XPosition,IsQuickEntry,AD_Client_ID,ColumnSpan,NumLines,IsAdvancedField,IsDefaultFocus,AD_Column_ID,EntityType,Created) VALUES ('N',200142,1,'N','N',110,'Y',203038,'N','There are two methods of making records unavailable in the system: One is to delete the record, the other is to de-activate the record. A de-activated record is not available for selection, but available for reports. +There are two reasons for de-activating and not deleting records: +(1) The system requires the record for audit purposes. +(2) The record is referenced by other records. E.g., you cannot delete a Business Partner, if there are invoices for this partner record existing. You de-activate the Business Partner and prevent that this record is used for future entries.','The record is active in the system','Active','e45bfa22-f210-4a87-9b0c-b3ab2da35161','Y','N',100,0,100,TO_DATE('2014-05-26 22:31:56','YYYY-MM-DD HH24:MI:SS'),'Y','Y',70,5,'N',0,2,1,'N','N',211245,'D',TO_DATE('2014-05-26 22:31:56','YYYY-MM-DD HH24:MI:SS')) +; + +-- migrate for anyone use red1 process in info panel start +INSERT INTO AD_InfoProcess +(ad_infoprocess_id, ad_infowindow_id, ad_client_id, ad_org_id, isactive,createdby, updatedby, seqno, name, ad_process_id, description, help, ad_infoprocess_uu) +(SELECT nextidfunc(200176,'N'), ad_infowindow_id, iw.ad_client_id, iw.ad_org_id, 'Y', 100, 100, 10, pr.name, iw.ad_process_id, pr.description, pr.help, generate_uuid() +FROM ad_infowindow iw INNER JOIN ad_process pr ON pr.ad_process_ID = iw.ad_process_ID +WHERE iw.ad_process_ID IS NOT NULL +); + +-- May 23, 2014 4:01:30 PM ICT +DELETE FROM AD_Field_Trl WHERE AD_Field_ID=202596 +; + +-- May 23, 2014 4:01:30 PM ICT +DELETE FROM AD_Field WHERE AD_Field_ID=202596 +; + +-- May 23, 2014 4:01:51 PM ICT +UPDATE AD_Column SET IsActive='N' WHERE AD_Column_ID=210944 +; + +SELECT register_migration_script('201405261604_IDEMPIERE-1334.sql') FROM dual +; diff --git a/migration/i2.0z/oracle/201405291604_IDEMPIERE-1334.sql b/migration/i2.0z/oracle/201405291604_IDEMPIERE-1334.sql new file mode 100644 index 0000000000..8df2a1eeb2 --- /dev/null +++ b/migration/i2.0z/oracle/201405291604_IDEMPIERE-1334.sql @@ -0,0 +1,68 @@ +SET SQLBLANKLINES ON +SET DEFINE OFF + +-- May 29, 2014 6:19:41 AM ICT +-- I forgot to set the DICTIONARY_ID_COMMENTS System Configurator +DELETE FROM AD_Field_Trl WHERE AD_Field_ID=203032 +; + +-- May 29, 2014 6:19:41 AM ICT +DELETE FROM AD_Field WHERE AD_Field_ID=203032 +; + +-- May 29, 2014 6:19:52 AM ICT +DELETE FROM AD_Field_Trl WHERE AD_Field_ID=203033 +; + +-- May 29, 2014 6:19:52 AM ICT +DELETE FROM AD_Field WHERE AD_Field_ID=203033 +; + +-- May 29, 2014 6:19:52 AM ICT +DELETE FROM AD_Field_Trl WHERE AD_Field_ID=203034 +; + +-- May 29, 2014 6:19:52 AM ICT +DELETE FROM AD_Field WHERE AD_Field_ID=203034 +; + +-- May 29, 2014 6:20:37 AM ICT +DELETE FROM AD_Column_Trl WHERE AD_Column_ID=211251 +; + +-- May 29, 2014 6:20:37 AM ICT +DELETE FROM AD_Column WHERE AD_Column_ID=211251 +; + +-- May 29, 2014 6:20:38 AM ICT +DELETE FROM AD_Column_Trl WHERE AD_Column_ID=211256 +; + +-- May 29, 2014 6:20:38 AM ICT +DELETE FROM AD_Column WHERE AD_Column_ID=211256 +; + +-- May 29, 2014 6:20:38 AM ICT +DELETE FROM AD_Column_Trl WHERE AD_Column_ID=211250 +; + +-- May 29, 2014 6:20:38 AM ICT +DELETE FROM AD_Column WHERE AD_Column_ID=211250 +; + +ALTER TABLE ad_infoprocess DROP COLUMN name +; + +ALTER TABLE ad_infoprocess DROP COLUMN description +; + +ALTER TABLE ad_infoprocess DROP COLUMN help +; + +-- May 29, 2014 6:21:41 AM ICT +INSERT INTO AD_Message (MsgType,MsgText,AD_Message_ID,EntityType,AD_Message_UU,Value,IsActive,Updated,CreatedBy,UpdatedBy,AD_Client_ID,AD_Org_ID,Created) VALUES ('M','Process Menu',200275,'D','c7cb8357-7a1f-46ab-9957-cda58431adfd','ProcessMenu','Y',TO_DATE('2014-05-29 06:21:35','YYYY-MM-DD HH24:MI:SS'),100,100,0,0,TO_DATE('2014-05-29 06:21:35','YYYY-MM-DD HH24:MI:SS')) +; + + +SELECT register_migration_script('201405291604_IDEMPIERE-1334.sql') FROM dual +; diff --git a/migration/i2.0z/oracle/201405291802_IDEMPIERE-1334.sql b/migration/i2.0z/oracle/201405291802_IDEMPIERE-1334.sql new file mode 100644 index 0000000000..7c08f6c4b1 --- /dev/null +++ b/migration/i2.0z/oracle/201405291802_IDEMPIERE-1334.sql @@ -0,0 +1,35 @@ +SET SQLBLANKLINES ON +SET DEFINE OFF + +-- May 29, 2014 6:00:45 PM COT +-- I forgot to set the DICTIONARY_ID_COMMENTS System Configurator +UPDATE AD_Column SET IsIdentifier='Y', SeqNo=1,Updated=TO_DATE('2014-05-29 18:00:45','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=211254 +; + +-- May 29, 2014 6:02:16 PM COT +UPDATE AD_Field SET SeqNoGrid=0,IsDisplayedGrid='N' WHERE AD_Field_ID=203030 +; + +-- May 29, 2014 6:02:16 PM COT +UPDATE AD_Field SET SeqNoGrid=10,IsDisplayedGrid='Y' WHERE AD_Field_ID=203036 +; + +-- May 29, 2014 6:02:16 PM COT +UPDATE AD_Field SET SeqNoGrid=20,IsDisplayedGrid='Y' WHERE AD_Field_ID=203035 +; + +-- May 29, 2014 6:02:16 PM COT +UPDATE AD_Field SET SeqNoGrid=30,IsDisplayedGrid='Y' WHERE AD_Field_ID=203037 +; + +-- May 29, 2014 6:02:16 PM COT +UPDATE AD_Field SET SeqNoGrid=40,IsDisplayedGrid='Y' WHERE AD_Field_ID=203038 +; + +-- May 29, 2014 6:02:16 PM COT +UPDATE AD_Field SET SeqNoGrid=50,IsDisplayedGrid='Y' WHERE AD_Field_ID=203031 +; + +SELECT register_migration_script('201405291802_IDEMPIERE-1334.sql') FROM dual +; + diff --git a/migration/i2.0z/oracle/201405301104_IDEMPIERE-1856.sql b/migration/i2.0z/oracle/201405301104_IDEMPIERE-1856.sql new file mode 100644 index 0000000000..d2c06d22c2 --- /dev/null +++ b/migration/i2.0z/oracle/201405301104_IDEMPIERE-1856.sql @@ -0,0 +1,79 @@ +CREATE OR REPLACE FUNCTION invoiceDiscount +( + p_C_Invoice_ID IN NUMBER, + p_PayDate IN DATE, + p_C_InvoicePaySchedule_ID IN NUMBER +) +RETURN NUMBER +/************************************************************************* + * The contents of this file are subject to the Compiere License. You may + * obtain a copy of the License at http://www.compiere.org/license.html + * Software is on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either + * express or implied. See the License for details. Code: Compiere ERP+CRM + * Copyright (C) 1999-2001 Jorg Janke, ComPiere, Inc. All Rights Reserved. + ************************************************************************* + * $Id: C_Invoice_Discount.sql,v 1.1 2006/04/21 17:51:58 jjanke Exp $ + *** + * Title: Calculate Payment Discount Amount + * Description: + * - Calculate discountable amount (i.e. with or without tax) + * - Calculate and return payment discount + ************************************************************************/ +AS + v_Amount NUMBER; + v_IsDiscountLineAmt CHAR(1); + v_GrandTotal NUMBER; + v_TotalLines NUMBER; + v_C_PaymentTerm_ID NUMBER(10); + v_C_Currency_ID NUMBER(10); + v_DocDate DATE; + v_PayDate DATE := SysDate; + v_IsPayScheduleValid CHAR(1); + +BEGIN + SELECT ci.IsDiscountLineAmt, i.GrandTotal, i.TotalLines, + i.C_PaymentTerm_ID, i.DateInvoiced, i.IsPayScheduleValid, C_Currency_ID + INTO v_IsDiscountLineAmt, v_GrandTotal, v_TotalLines, + v_C_PaymentTerm_ID, v_DocDate, v_IsPayScheduleValid, v_C_Currency_ID + FROM AD_ClientInfo ci, C_Invoice i + WHERE ci.AD_Client_ID=i.AD_Client_ID + AND i.C_Invoice_ID=p_C_Invoice_ID; + -- What Amount is the Discount Base? + IF (v_IsDiscountLineAmt = 'Y') THEN + v_Amount := v_TotalLines; + ELSE + v_Amount := v_GrandTotal; + END IF; + + -- Anything to discount? + IF (v_Amount = 0) THEN + RETURN 0; + END IF; + IF (p_PayDate IS NOT NULL) THEN + v_PayDate := p_PayDate; + END IF; + + -- Valid Payment Schedule + IF (v_IsPayScheduleValid='Y' AND p_C_InvoicePaySchedule_ID > 0) THEN + SELECT COALESCE(MAX(DiscountAmt),0) + INTO v_Amount + FROM C_InvoicePaySchedule + WHERE C_InvoicePaySchedule_ID=p_C_InvoicePaySchedule_ID + AND DiscountDate <= v_PayDate; + -- + RETURN v_Amount; + END IF; + + -- return discount amount + RETURN paymentTermDiscount (v_Amount, v_C_Currency_ID, v_C_PaymentTerm_ID, v_DocDate, p_PayDate); + +-- Most likely if invoice not found +EXCEPTION + WHEN OTHERS THEN + RETURN NULL; +END invoiceDiscount; +/ + +SELECT register_migration_script('201405301104_IDEMPIERE-1856.sql') FROM dual +; + diff --git a/migration/i2.0z/oracle/201405301149_IDEMPIERE-1953.sql b/migration/i2.0z/oracle/201405301149_IDEMPIERE-1953.sql new file mode 100644 index 0000000000..ad344a46a2 --- /dev/null +++ b/migration/i2.0z/oracle/201405301149_IDEMPIERE-1953.sql @@ -0,0 +1,4 @@ +-- just for postgresql +SELECT register_migration_script('201405301149_IDEMPIERE-1953.sql') FROM dual +; + diff --git a/migration/i2.0z/postgresql/201405261604_IDEMPIERE-1334.sql b/migration/i2.0z/postgresql/201405261604_IDEMPIERE-1334.sql new file mode 100644 index 0000000000..efa6450cda --- /dev/null +++ b/migration/i2.0z/postgresql/201405261604_IDEMPIERE-1334.sql @@ -0,0 +1,273 @@ +-- May 26, 2014 10:31:26 PM ICT +-- IDEMPIERE-1334 Run one or more processes from Info Window +INSERT INTO AD_Table (ImportTable,CopyColumnsFromTable,IsSecurityEnabled,AccessLevel,LoadSeq,AD_Window_ID,AD_Table_ID,IsHighVolume,IsView,IsChangeLog,EntityType,ReplicationType,AD_Table_UU,IsCentrallyMaintained,IsDeleteable,TableName,Description,Name,IsActive,AD_Org_ID,CreatedBy,Updated,UpdatedBy,Processing,DatabaseViewDrop,AD_Client_ID,Created) VALUES ('N','N','N','4',0,385,200129,'N','N','Y','D','L','399fcb47-f46c-4789-9e45-962cc5379c16','Y','Y','AD_InfoProcess','define process for info window','Info Process','Y',0,100,TO_TIMESTAMP('2014-05-26 22:31:25','YYYY-MM-DD HH24:MI:SS'),100,'N','N',0,TO_TIMESTAMP('2014-05-26 22:31:25','YYYY-MM-DD HH24:MI:SS')) +; + +-- May 26, 2014 10:31:27 PM ICT +INSERT INTO AD_Sequence (StartNewYear,CurrentNextSys,IsTableID,CurrentNext,IsAudited,IsAutoSequence,AD_Sequence_ID,Description,Name,IncrementNo,AD_Sequence_UU,AD_Org_ID,CreatedBy,Updated,UpdatedBy,IsActive,StartNo,AD_Client_ID,Created) VALUES ('N',200000,'Y',1000000,'N','Y',200176,'Table AD_InfoProcess','AD_InfoProcess',1,'48700d65-3ba4-4888-8242-6af9a613206a',0,100,TO_TIMESTAMP('2014-05-26 22:31:26','YYYY-MM-DD HH24:MI:SS'),100,'Y',1000000,0,TO_TIMESTAMP('2014-05-26 22:31:26','YYYY-MM-DD HH24:MI:SS')) +; + +-- May 26, 2014 10:31:28 PM ICT +INSERT INTO AD_Element (ColumnName,AD_Element_ID,Name,PrintName,AD_Element_UU,AD_Org_ID,CreatedBy,UpdatedBy,IsActive,AD_Client_ID,EntityType,Created,Updated) VALUES ('AD_InfoProcess_ID',202712,'Info Process','Info Process','ebfa3db8-e6b2-43aa-9eaa-e3dc1b2eb7f1',0,100,100,'Y',0,'D',TO_TIMESTAMP('2014-05-26 22:31:27','YYYY-MM-DD HH24:MI:SS'),TO_TIMESTAMP('2014-05-26 22:31:27','YYYY-MM-DD HH24:MI:SS')) +; + +-- May 26, 2014 10:31:28 PM ICT +INSERT INTO AD_Column (IsSyncDatabase,Version,AD_Column_ID,IsMandatory,IsTranslated,IsIdentifier,IsParent,FieldLength,IsSelectionColumn,IsKey,IsAutocomplete,IsAllowLogging,AD_Column_UU,IsUpdateable,ColumnName,Name,IsAllowCopy,Updated,CreatedBy,AD_Org_ID,IsActive,Created,UpdatedBy,IsToolbarButton,IsAlwaysUpdateable,AD_Client_ID,EntityType,IsEncrypted,IsSecure,FKConstraintType,AD_Element_ID,AD_Reference_ID,AD_Table_ID) VALUES ('Y',0.0,211241,'Y','N','N','N',10,'N','Y','N','Y','e3154b48-b2ac-4ad2-ba43-92744e8c6a4c','N','AD_InfoProcess_ID','Info Process','N',TO_TIMESTAMP('2014-05-26 22:31:28','YYYY-MM-DD HH24:MI:SS'),100,0,'Y',TO_TIMESTAMP('2014-05-26 22:31:28','YYYY-MM-DD HH24:MI:SS'),100,'N','N',0,'D','N','N','N',202712,13,200129) +; + +-- May 26, 2014 10:31:28 PM ICT +CREATE TABLE AD_InfoProcess (AD_InfoProcess_ID NUMERIC(10) NOT NULL, CONSTRAINT AD_InfoProcess_Key PRIMARY KEY (AD_InfoProcess_ID)) +; + +-- May 26, 2014 10:31:29 PM ICT +INSERT INTO AD_Element (ColumnName,AD_Element_ID,Name,PrintName,AD_Element_UU,AD_Org_ID,CreatedBy,UpdatedBy,IsActive,AD_Client_ID,EntityType,Created,Updated) VALUES ('AD_InfoProcess_UU',202713,'AD_InfoProcess_UU','AD_InfoProcess_UU','dde8ccd5-449b-4b9b-84a2-720e77eff87b',0,100,100,'Y',0,'D',TO_TIMESTAMP('2014-05-26 22:31:29','YYYY-MM-DD HH24:MI:SS'),TO_TIMESTAMP('2014-05-26 22:31:29','YYYY-MM-DD HH24:MI:SS')) +; + +-- May 26, 2014 10:31:30 PM ICT +INSERT INTO AD_Column (IsSyncDatabase,Version,AD_Column_ID,IsMandatory,IsTranslated,IsIdentifier,IsParent,FieldLength,IsSelectionColumn,IsKey,IsAutocomplete,IsAllowLogging,AD_Column_UU,IsUpdateable,ColumnName,Name,IsAllowCopy,Updated,CreatedBy,AD_Org_ID,IsActive,Created,UpdatedBy,IsToolbarButton,IsAlwaysUpdateable,AD_Client_ID,EntityType,IsEncrypted,IsSecure,FKConstraintType,AD_Element_ID,AD_Reference_ID,AD_Table_ID) VALUES ('Y',0.0,211242,'Y','N','N','N',36,'N','N','N','Y','8f961362-5939-48a4-8c8d-8d8b5d86a83e','N','AD_InfoProcess_UU','AD_InfoProcess_UU','N',TO_TIMESTAMP('2014-05-26 22:31:29','YYYY-MM-DD HH24:MI:SS'),100,0,'Y',TO_TIMESTAMP('2014-05-26 22:31:29','YYYY-MM-DD HH24:MI:SS'),100,'N','N',0,'D','N','N','N',202713,10,200129) +; + +-- May 26, 2014 10:31:30 PM ICT +ALTER TABLE AD_InfoProcess ADD COLUMN AD_InfoProcess_UU VARCHAR(36) NOT NULL +; + +-- May 26, 2014 10:31:30 PM ICT +ALTER TABLE AD_InfoProcess ADD CONSTRAINT AD_InfoProcess_UU_idx UNIQUE (AD_InfoProcess_UU) +; + +-- May 26, 2014 10:31:31 PM ICT +INSERT INTO AD_Column (IsSyncDatabase,Version,AD_Column_ID,IsMandatory,IsTranslated,IsIdentifier,IsParent,FieldLength,IsSelectionColumn,IsKey,IsAutocomplete,IsAllowLogging,AD_Column_UU,IsUpdateable,ColumnName,Description,DefaultValue,Help,Name,IsAllowCopy,Updated,CreatedBy,AD_Org_ID,IsActive,Created,UpdatedBy,IsToolbarButton,IsAlwaysUpdateable,AD_Client_ID,EntityType,IsEncrypted,IsSecure,FKConstraintName,FKConstraintType,AD_Element_ID,AD_Reference_ID,AD_Table_ID,AD_Val_Rule_ID) VALUES ('Y',0.0,211243,'Y','N','N','N',10,'N','N','N','Y','e8fa9743-e852-4fb3-a8ba-aba7190f5d26','N','AD_Client_ID','Client/Tenant for this installation.','@#AD_Client_ID@','A Client is a company or a legal entity. You cannot share data between Clients. Tenant is a synonym for Client.','Client','N',TO_TIMESTAMP('2014-05-26 22:31:30','YYYY-MM-DD HH24:MI:SS'),100,0,'Y',TO_TIMESTAMP('2014-05-26 22:31:30','YYYY-MM-DD HH24:MI:SS'),100,'N','N',0,'D','N','N','ADClient_ADInfoProcess','N',102,19,200129,129) +; + +-- May 26, 2014 10:31:31 PM ICT +ALTER TABLE AD_InfoProcess ADD COLUMN AD_Client_ID NUMERIC(10) NOT NULL +; + +-- May 26, 2014 10:31:31 PM ICT +INSERT INTO AD_Column (IsSyncDatabase,Version,AD_Column_ID,IsMandatory,IsTranslated,IsIdentifier,IsParent,FieldLength,IsSelectionColumn,IsKey,IsAutocomplete,IsAllowLogging,AD_Column_UU,IsUpdateable,ColumnName,Description,DefaultValue,Help,Name,IsAllowCopy,Updated,CreatedBy,AD_Org_ID,IsActive,Created,UpdatedBy,IsToolbarButton,IsAlwaysUpdateable,AD_Client_ID,EntityType,IsEncrypted,IsSecure,FKConstraintName,FKConstraintType,AD_Element_ID,AD_Reference_ID,AD_Table_ID,AD_Val_Rule_ID) VALUES ('Y',0.0,211244,'Y','N','N','N',10,'N','N','N','Y','48046a19-4d3c-40e6-93f2-49858061c1ff','N','AD_Org_ID','Organizational entity within client','@#AD_Org_ID@','An organization is a unit of your client or legal entity - examples are store, department. You can share data between organizations.','Organization','N',TO_TIMESTAMP('2014-05-26 22:31:31','YYYY-MM-DD HH24:MI:SS'),100,0,'Y',TO_TIMESTAMP('2014-05-26 22:31:31','YYYY-MM-DD HH24:MI:SS'),100,'N','N',0,'D','N','N','ADOrg_ADInfoProcess','N',113,19,200129,104) +; + +-- May 26, 2014 10:31:31 PM ICT +ALTER TABLE AD_InfoProcess ADD COLUMN AD_Org_ID NUMERIC(10) NOT NULL +; + +-- May 26, 2014 10:31:32 PM ICT +INSERT INTO AD_Column (IsSyncDatabase,Version,AD_Column_ID,IsMandatory,IsTranslated,IsIdentifier,IsParent,FieldLength,IsSelectionColumn,IsKey,IsAutocomplete,IsAllowLogging,AD_Column_UU,IsUpdateable,ColumnName,Description,DefaultValue,Help,Name,IsAllowCopy,Updated,CreatedBy,AD_Org_ID,IsActive,Created,UpdatedBy,IsToolbarButton,IsAlwaysUpdateable,AD_Client_ID,EntityType,IsEncrypted,IsSecure,FKConstraintType,AD_Element_ID,AD_Reference_ID,AD_Table_ID) VALUES ('Y',0.0,211245,'Y','N','N','N',1,'N','N','N','Y','0d5a6a7a-b436-4958-814a-18ecafbc8971','Y','IsActive','The record is active in the system','Y','There are two methods of making records unavailable in the system: One is to delete the record, the other is to de-activate the record. A de-activated record is not available for selection, but available for reports. +There are two reasons for de-activating and not deleting records: +(1) The system requires the record for audit purposes. +(2) The record is referenced by other records. E.g., you cannot delete a Business Partner, if there are invoices for this partner record existing. You de-activate the Business Partner and prevent that this record is used for future entries.','Active','N',TO_TIMESTAMP('2014-05-26 22:31:31','YYYY-MM-DD HH24:MI:SS'),100,0,'Y',TO_TIMESTAMP('2014-05-26 22:31:31','YYYY-MM-DD HH24:MI:SS'),100,'N','N',0,'D','N','N','N',348,20,200129) +; + +-- May 26, 2014 10:31:32 PM ICT +ALTER TABLE AD_InfoProcess ADD COLUMN IsActive CHAR(1) DEFAULT 'Y' CHECK (IsActive IN ('Y','N')) NOT NULL +; + +-- May 26, 2014 10:31:33 PM ICT +INSERT INTO AD_Column (IsSyncDatabase,Version,AD_Column_ID,IsMandatory,IsTranslated,IsIdentifier,IsParent,FieldLength,IsSelectionColumn,IsKey,IsAutocomplete,IsAllowLogging,AD_Column_UU,IsUpdateable,ColumnName,Description,DefaultValue,Help,Name,IsAllowCopy,Updated,CreatedBy,AD_Org_ID,IsActive,Created,UpdatedBy,IsToolbarButton,IsAlwaysUpdateable,AD_Client_ID,EntityType,IsEncrypted,IsSecure,FKConstraintType,AD_Element_ID,AD_Reference_ID,AD_Table_ID) VALUES ('Y',0.0,211246,'Y','N','N','N',29,'N','N','N','Y','a8315f0c-3cbd-4092-bcc7-8e1f0bc4021c','N','Created','Date this record was created','SYSDATE','The Created field indicates the date that this record was created.','Created','N',TO_TIMESTAMP('2014-05-26 22:31:32','YYYY-MM-DD HH24:MI:SS'),100,0,'Y',TO_TIMESTAMP('2014-05-26 22:31:32','YYYY-MM-DD HH24:MI:SS'),100,'N','N',0,'D','N','N','N',245,16,200129) +; + +-- May 26, 2014 10:31:33 PM ICT +ALTER TABLE AD_InfoProcess ADD COLUMN Created TIMESTAMP DEFAULT statement_timestamp() NOT NULL +; + +-- May 26, 2014 10:31:34 PM ICT +INSERT INTO AD_Column (IsSyncDatabase,Version,AD_Column_ID,IsMandatory,IsTranslated,IsIdentifier,IsParent,FieldLength,IsSelectionColumn,IsKey,IsAutocomplete,IsAllowLogging,AD_Column_UU,IsUpdateable,ColumnName,Description,Help,Name,IsAllowCopy,Updated,CreatedBy,AD_Org_ID,IsActive,Created,UpdatedBy,IsToolbarButton,IsAlwaysUpdateable,AD_Client_ID,EntityType,IsEncrypted,IsSecure,FKConstraintType,AD_Element_ID,AD_Reference_ID,AD_Reference_Value_ID,AD_Table_ID) VALUES ('Y',0.0,211247,'Y','N','N','N',10,'N','N','N','Y','f2e43604-537c-46a7-a08a-425589a290de','N','CreatedBy','User who created this records','The Created By field indicates the user who created this record.','Created By','N',TO_TIMESTAMP('2014-05-26 22:31:33','YYYY-MM-DD HH24:MI:SS'),100,0,'Y',TO_TIMESTAMP('2014-05-26 22:31:33','YYYY-MM-DD HH24:MI:SS'),100,'N','N',0,'D','N','N','N',246,18,110,200129) +; + +-- May 26, 2014 10:31:34 PM ICT +ALTER TABLE AD_InfoProcess ADD COLUMN CreatedBy NUMERIC(10) NOT NULL +; + +-- May 26, 2014 10:31:35 PM ICT +INSERT INTO AD_Column (IsSyncDatabase,Version,AD_Column_ID,IsMandatory,IsTranslated,IsIdentifier,IsParent,FieldLength,IsSelectionColumn,IsKey,IsAutocomplete,IsAllowLogging,AD_Column_UU,IsUpdateable,ColumnName,Description,DefaultValue,Help,Name,IsAllowCopy,Updated,CreatedBy,AD_Org_ID,IsActive,Created,UpdatedBy,IsToolbarButton,IsAlwaysUpdateable,AD_Client_ID,EntityType,IsEncrypted,IsSecure,FKConstraintType,AD_Element_ID,AD_Reference_ID,AD_Table_ID) VALUES ('Y',0.0,211248,'Y','N','N','N',29,'N','N','N','Y','87143907-1038-4c5d-90f6-3114a6fc7edf','N','Updated','Date this record was updated','SYSDATE','The Updated field indicates the date that this record was updated.','Updated','N',TO_TIMESTAMP('2014-05-26 22:31:34','YYYY-MM-DD HH24:MI:SS'),100,0,'Y',TO_TIMESTAMP('2014-05-26 22:31:34','YYYY-MM-DD HH24:MI:SS'),100,'N','N',0,'D','N','N','N',607,16,200129) +; + +-- May 26, 2014 10:31:35 PM ICT +ALTER TABLE AD_InfoProcess ADD COLUMN Updated TIMESTAMP DEFAULT statement_timestamp() NOT NULL +; + +-- May 26, 2014 10:31:35 PM ICT +INSERT INTO AD_Column (IsSyncDatabase,Version,AD_Column_ID,IsMandatory,IsTranslated,IsIdentifier,IsParent,FieldLength,IsSelectionColumn,IsKey,IsAutocomplete,IsAllowLogging,AD_Column_UU,IsUpdateable,ColumnName,Description,Help,Name,IsAllowCopy,Updated,CreatedBy,AD_Org_ID,IsActive,Created,UpdatedBy,IsToolbarButton,IsAlwaysUpdateable,AD_Client_ID,EntityType,IsEncrypted,IsSecure,FKConstraintType,AD_Element_ID,AD_Reference_ID,AD_Reference_Value_ID,AD_Table_ID) VALUES ('Y',0.0,211249,'Y','N','N','N',10,'N','N','N','Y','197f9f68-6340-45a8-9d75-9d027f8bcc75','N','UpdatedBy','User who updated this records','The Updated By field indicates the user who updated this record.','Updated By','N',TO_TIMESTAMP('2014-05-26 22:31:35','YYYY-MM-DD HH24:MI:SS'),100,0,'Y',TO_TIMESTAMP('2014-05-26 22:31:35','YYYY-MM-DD HH24:MI:SS'),100,'N','N',0,'D','N','N','N',608,18,110,200129) +; + +-- May 26, 2014 10:31:35 PM ICT +ALTER TABLE AD_InfoProcess ADD COLUMN UpdatedBy NUMERIC(10) NOT NULL +; + +-- May 26, 2014 10:31:36 PM ICT +INSERT INTO AD_Column (IsSyncDatabase,Version,AD_Column_ID,IsMandatory,IsTranslated,IsIdentifier,IsParent,FieldLength,IsSelectionColumn,IsKey,IsAutocomplete,IsAllowLogging,AD_Column_UU,IsUpdateable,ColumnName,Description,Help,Name,IsAllowCopy,Updated,CreatedBy,AD_Org_ID,IsActive,Created,UpdatedBy,IsToolbarButton,IsAlwaysUpdateable,AD_Client_ID,EntityType,IsEncrypted,IsSecure,FKConstraintType,AD_Element_ID,AD_Reference_ID,AD_Table_ID) VALUES ('Y',0.0,211250,'Y','N','Y','N',60,'Y','N','N','Y','cba0a7f1-a35e-4410-b53d-b47a0a81b8d5','Y','Name','Alphanumeric identifier of the entity','The name of an entity (record) is used as an default search option in addition to the search key. The name is up to 60 characters in length.','Name','Y',TO_TIMESTAMP('2014-05-26 22:31:35','YYYY-MM-DD HH24:MI:SS'),100,0,'Y',TO_TIMESTAMP('2014-05-26 22:31:35','YYYY-MM-DD HH24:MI:SS'),100,'N','N',0,'D','N','N','N',469,10,200129) +; + +-- May 26, 2014 10:31:36 PM ICT +ALTER TABLE AD_InfoProcess ADD COLUMN Name VARCHAR(60) NOT NULL +; + +-- May 26, 2014 10:31:37 PM ICT +INSERT INTO AD_Column (IsSyncDatabase,Version,AD_Column_ID,IsMandatory,IsTranslated,IsIdentifier,IsParent,FieldLength,IsSelectionColumn,IsKey,IsAutocomplete,IsAllowLogging,AD_Column_UU,IsUpdateable,ColumnName,Description,Help,Name,IsAllowCopy,Updated,CreatedBy,AD_Org_ID,IsActive,Created,UpdatedBy,IsToolbarButton,IsAlwaysUpdateable,AD_Client_ID,EntityType,IsEncrypted,IsSecure,FKConstraintType,AD_Element_ID,AD_Reference_ID,AD_Table_ID) VALUES ('Y',0.0,211251,'N','N','N','N',255,'Y','N','N','Y','da7faea4-1447-4912-975d-9916325f892c','Y','Description','Optional short description of the record','A description is limited to 255 characters.','Description','Y',TO_TIMESTAMP('2014-05-26 22:31:36','YYYY-MM-DD HH24:MI:SS'),100,0,'Y',TO_TIMESTAMP('2014-05-26 22:31:36','YYYY-MM-DD HH24:MI:SS'),100,'N','N',0,'D','N','N','N',275,10,200129) +; + +-- May 26, 2014 10:31:37 PM ICT +ALTER TABLE AD_InfoProcess ADD COLUMN Description VARCHAR(255) DEFAULT NULL +; + +-- May 26, 2014 10:31:38 PM ICT +INSERT INTO AD_Column (IsSyncDatabase,Version,AD_Column_ID,IsMandatory,IsTranslated,IsIdentifier,IsParent,FieldLength,IsSelectionColumn,IsKey,IsAutocomplete,IsAllowLogging,AD_Column_UU,IsUpdateable,ColumnName,Description,Help,Name,IsAllowCopy,Updated,CreatedBy,AD_Org_ID,IsActive,Created,UpdatedBy,IsToolbarButton,IsAlwaysUpdateable,AD_Client_ID,EntityType,IsEncrypted,IsSecure,FKConstraintType,AD_Element_ID,AD_Reference_ID,AD_Table_ID) VALUES ('Y',0.0,211252,'N','N','N','N',120,'N','N','N','Y','54fdf7c3-564a-48ea-af3c-314efca2f0ed','Y','ImageURL','URL of image','URL of image; The image is not stored in the database, but retrieved at runtime. The image can be a gif, jpeg or png.','Image URL','Y',TO_TIMESTAMP('2014-05-26 22:31:37','YYYY-MM-DD HH24:MI:SS'),100,0,'Y',TO_TIMESTAMP('2014-05-26 22:31:37','YYYY-MM-DD HH24:MI:SS'),100,'N','N',0,'D','N','N','N',1720,10,200129) +; + +-- May 26, 2014 10:31:38 PM ICT +ALTER TABLE AD_InfoProcess ADD COLUMN ImageURL VARCHAR(120) DEFAULT NULL +; + +-- May 26, 2014 10:31:38 PM ICT +INSERT INTO AD_Column (IsSyncDatabase,Version,AD_Column_ID,IsMandatory,IsTranslated,IsIdentifier,IsParent,FieldLength,IsSelectionColumn,IsKey,IsAutocomplete,IsAllowLogging,AD_Column_UU,IsUpdateable,ColumnName,Description,DefaultValue,Help,Name,IsAllowCopy,Updated,CreatedBy,AD_Org_ID,IsActive,Created,UpdatedBy,IsToolbarButton,IsAlwaysUpdateable,AD_Client_ID,EntityType,IsEncrypted,IsSecure,FKConstraintType,AD_Element_ID,AD_Reference_ID,AD_Table_ID) VALUES ('Y',0.0,211253,'Y','N','N','N',10,'N','N','N','Y','b9449134-fe06-4a9a-b1a6-54077974de21','Y','SeqNo','Method of ordering records; lowest number comes first','@SQL=SELECT NVL(MAX(SeqNo),0)+10 AS DefaultValue FROM AD_InfoProcess WHERE AD_InfoWindow_ID=@AD_InfoWindow_ID@','The Sequence indicates the order of records','Sequence','N',TO_TIMESTAMP('2014-05-26 22:31:38','YYYY-MM-DD HH24:MI:SS'),100,0,'Y',TO_TIMESTAMP('2014-05-26 22:31:38','YYYY-MM-DD HH24:MI:SS'),100,'N','N',0,'D','N','N','N',566,11,200129) +; + +-- May 26, 2014 10:31:38 PM ICT +ALTER TABLE AD_InfoProcess ADD COLUMN SeqNo NUMERIC(10) NOT NULL +; + +-- May 26, 2014 10:31:39 PM ICT +INSERT INTO AD_Column (IsSyncDatabase,Version,AD_Column_ID,IsMandatory,IsTranslated,IsIdentifier,IsParent,FieldLength,IsSelectionColumn,IsKey,IsAutocomplete,IsAllowLogging,AD_Column_UU,IsUpdateable,ColumnName,Description,Help,Name,IsAllowCopy,Updated,CreatedBy,AD_Org_ID,IsActive,Created,UpdatedBy,IsToolbarButton,IsAlwaysUpdateable,AD_Client_ID,EntityType,IsEncrypted,IsSecure,FKConstraintName,FKConstraintType,AD_Element_ID,AD_Reference_ID,AD_Table_ID) VALUES ('Y',0.0,211254,'Y','N','N','N',10,'N','N','N','Y','be4dc8ea-58bf-4238-bff2-71099c2f36f9','Y','AD_Process_ID','Process or Report','The Process field identifies a unique Process or Report in the system.','Process','Y',TO_TIMESTAMP('2014-05-26 22:31:38','YYYY-MM-DD HH24:MI:SS'),100,0,'Y',TO_TIMESTAMP('2014-05-26 22:31:38','YYYY-MM-DD HH24:MI:SS'),100,'N','N',0,'D','N','N','ADProcess_ADInfoProcess','N',117,19,200129) +; + +-- May 26, 2014 10:31:39 PM ICT +ALTER TABLE AD_InfoProcess ADD COLUMN AD_Process_ID NUMERIC(10) NOT NULL +; + +-- May 26, 2014 10:31:40 PM ICT +INSERT INTO AD_Column (IsSyncDatabase,Version,AD_Column_ID,IsMandatory,IsTranslated,IsIdentifier,IsParent,FieldLength,IsSelectionColumn,IsKey,IsAutocomplete,IsAllowLogging,AD_Column_UU,IsUpdateable,ColumnName,Description,Help,Name,IsAllowCopy,Updated,CreatedBy,AD_Org_ID,IsActive,Created,UpdatedBy,IsToolbarButton,IsAlwaysUpdateable,AD_Client_ID,EntityType,IsEncrypted,IsSecure,FKConstraintName,FKConstraintType,AD_Element_ID,AD_Reference_ID,AD_Table_ID) VALUES ('Y',0.0,211255,'N','N','N','Y',10,'N','N','N','Y','d9a775c3-dd5c-4e91-8416-60b78c33eb4e','N','AD_InfoWindow_ID','Info and search/select Window','The Info window is used to search and select records as well as display information relevant to the selection.','Info Window','Y',TO_TIMESTAMP('2014-05-26 22:31:39','YYYY-MM-DD HH24:MI:SS'),100,0,'Y',TO_TIMESTAMP('2014-05-26 22:31:39','YYYY-MM-DD HH24:MI:SS'),100,'N','N',0,'D','N','N','ADInfoWindow_ADInfoProcess','C',3068,19,200129) +; + +-- May 26, 2014 10:31:40 PM ICT +ALTER TABLE AD_InfoProcess ADD COLUMN AD_InfoWindow_ID NUMERIC(10) DEFAULT NULL +; + +-- May 26, 2014 10:31:41 PM ICT +INSERT INTO AD_Column (SeqNoSelection,IsSyncDatabase,Version,AD_Column_ID,IsMandatory,IsTranslated,IsIdentifier,SeqNo,IsParent,FieldLength,IsSelectionColumn,IsKey,IsAutocomplete,IsAllowLogging,AD_Column_UU,IsUpdateable,ColumnName,Description,Help,Name,IsAllowCopy,Updated,CreatedBy,AD_Org_ID,IsActive,Created,UpdatedBy,IsToolbarButton,IsAlwaysUpdateable,AD_Client_ID,EntityType,IsEncrypted,IsSecure,FKConstraintType,AD_Element_ID,AD_Reference_ID,AD_Table_ID) VALUES (0,'Y',0,211256,'N','N','N',0,'N',2000,'N','N','N','Y','54387a92-4caa-4ab2-a765-51cf779a537c','Y','Help','Comment or Hint','The Help field contains a hint, comment or help about the use of this item.','Comment/Help','Y',TO_TIMESTAMP('2014-05-26 22:31:40','YYYY-MM-DD HH24:MI:SS'),100,0,'Y',TO_TIMESTAMP('2014-05-26 22:31:40','YYYY-MM-DD HH24:MI:SS'),100,'N','N',0,'D','N','N','N',326,14,200129) +; + +-- May 26, 2014 10:31:41 PM ICT +ALTER TABLE AD_InfoProcess ADD COLUMN Help VARCHAR(2000) DEFAULT NULL +; + +-- May 26, 2014 10:31:41 PM ICT +INSERT INTO AD_Element (ColumnName,AD_Element_ID,Help,Name,Description,PrintName,AD_Element_UU,AD_Org_ID,CreatedBy,UpdatedBy,IsActive,AD_Client_ID,EntityType,Created,Updated) VALUES ('LayoutType',202714,'Process info can display as button, list, menu','LayoutType','Layout type of info process','Layout Type','913eafda-0cdc-4c44-85f8-487d77a3787c',0,100,100,'Y',0,'D',TO_TIMESTAMP('2014-05-26 22:31:41','YYYY-MM-DD HH24:MI:SS'),TO_TIMESTAMP('2014-05-26 22:31:41','YYYY-MM-DD HH24:MI:SS')) +; + +-- May 26, 2014 10:31:42 PM ICT +INSERT INTO AD_Reference (AD_Reference_ID,Name,EntityType,AD_Reference_UU,IsOrderByValue,Description,ValidationType,AD_Org_ID,CreatedBy,Updated,IsActive,Created,UpdatedBy,AD_Client_ID) VALUES (200083,'AD_InfoProcess LayoutType','D','2171ebd2-e11a-4612-9885-128f155d65e8','N','Define layout type of info process button','L',0,100,TO_TIMESTAMP('2014-05-26 22:31:42','YYYY-MM-DD HH24:MI:SS'),'Y',TO_TIMESTAMP('2014-05-26 22:31:42','YYYY-MM-DD HH24:MI:SS'),100,0) +; + +-- May 26, 2014 10:31:43 PM ICT +INSERT INTO AD_Ref_List (AD_Ref_List_ID,AD_Reference_ID,Description,Name,AD_Ref_List_UU,Value,Created,CreatedBy,Updated,UpdatedBy,IsActive,EntityType,AD_Client_ID,AD_Org_ID) VALUES (200185,200083,'Display as button','Button','6884dcd1-bc9a-4d16-9b2c-fe40968747f8','B',TO_TIMESTAMP('2014-05-26 22:31:42','YYYY-MM-DD HH24:MI:SS'),100,TO_TIMESTAMP('2014-05-26 22:31:42','YYYY-MM-DD HH24:MI:SS'),100,'Y','D',0,0) +; + +-- May 26, 2014 10:31:44 PM ICT +INSERT INTO AD_Ref_List (AD_Ref_List_ID,AD_Reference_ID,Description,Name,AD_Ref_List_UU,Value,Created,CreatedBy,Updated,UpdatedBy,IsActive,EntityType,AD_Client_ID,AD_Org_ID) VALUES (200186,200083,'Display as menu on a gear button','Menu','7b539591-296a-43ee-916c-c87c35acc84d','M',TO_TIMESTAMP('2014-05-26 22:31:43','YYYY-MM-DD HH24:MI:SS'),100,TO_TIMESTAMP('2014-05-26 22:31:43','YYYY-MM-DD HH24:MI:SS'),100,'Y','D',0,0) +; + +-- May 26, 2014 10:31:44 PM ICT +INSERT INTO AD_Ref_List (AD_Ref_List_ID,AD_Reference_ID,Description,Name,AD_Ref_List_UU,Value,Created,CreatedBy,Updated,UpdatedBy,IsActive,EntityType,AD_Client_ID,AD_Org_ID) VALUES (200187,200083,'Display as list','List','ff0cba3e-e82c-4aa8-9f9b-bedf681b822d','L',TO_TIMESTAMP('2014-05-26 22:31:44','YYYY-MM-DD HH24:MI:SS'),100,TO_TIMESTAMP('2014-05-26 22:31:44','YYYY-MM-DD HH24:MI:SS'),100,'Y','D',0,0) +; + +-- May 26, 2014 10:31:45 PM ICT +INSERT INTO AD_Column (SeqNoSelection,IsSyncDatabase,Version,AD_Column_ID,IsMandatory,IsTranslated,IsIdentifier,SeqNo,IsParent,FieldLength,IsSelectionColumn,IsKey,IsAutocomplete,IsAllowLogging,AD_Column_UU,IsUpdateable,ColumnName,Description,Help,Name,IsAllowCopy,Updated,CreatedBy,AD_Org_ID,IsActive,Created,UpdatedBy,IsToolbarButton,IsAlwaysUpdateable,AD_Client_ID,EntityType,IsEncrypted,IsSecure,FKConstraintType,AD_Element_ID,AD_Reference_ID,AD_Reference_Value_ID,AD_Table_ID) VALUES (0,'Y',0,211257,'N','N','N',0,'N',1,'N','N','N','Y','a0e8f5b5-ac5f-44ba-a2c9-060dd3231c4e','Y','LayoutType','Layout type of info process','Process info can display as button, list, menu','LayoutType','Y',TO_TIMESTAMP('2014-05-26 22:31:45','YYYY-MM-DD HH24:MI:SS'),100,0,'Y',TO_TIMESTAMP('2014-05-26 22:31:45','YYYY-MM-DD HH24:MI:SS'),100,'N','N',0,'D','N','N','N',202714,17,200083,200129) +; + +-- May 26, 2014 10:31:45 PM ICT +ALTER TABLE AD_InfoProcess ADD COLUMN LayoutType VARCHAR(1) DEFAULT NULL +; + +-- 28/05/2014 01:24:40 PM COT +UPDATE AD_Column SET IsMandatory='Y', DefaultValue='B',Updated=TO_TIMESTAMP('2014-05-28 13:24:40','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=211257 +; + +-- 28/05/2014 01:24:44 PM COT +INSERT INTO t_alter_column values('ad_infoprocess','LayoutType','VARCHAR(10)',null,'B') +; + +-- 28/05/2014 01:24:44 PM COT +INSERT INTO t_alter_column values('ad_infoprocess','LayoutType',null,'NOT NULL',null) +; + +-- May 26, 2014 10:31:48 PM ICT +INSERT INTO AD_Tab (ImportFields,Processing,IsSingleRow,AD_Window_ID,SeqNo,IsTranslationTab,IsSortTab,HasTree,IsInfoTab,IsReadOnly,IsInsertRecord,IsAdvancedTab,TabLevel,AD_Tab_UU,EntityType,Name,AD_Tab_ID,AD_Org_ID,Created,CreatedBy,Updated,UpdatedBy,IsActive,AD_Table_ID,AD_Client_ID,TreeDisplayedOn) VALUES ('N','N','Y',385,60,'N','N','N','N','N','Y','N',1,'2a39f93a-2062-404a-8e28-19fc45982162','D','Process',200142,0,TO_TIMESTAMP('2014-05-26 22:31:47','YYYY-MM-DD HH24:MI:SS'),100,TO_TIMESTAMP('2014-05-26 22:31:47','YYYY-MM-DD HH24:MI:SS'),100,'Y',200129,0,'B') +; + +-- May 26, 2014 10:31:49 PM ICT +INSERT INTO AD_Field (IsEncrypted,AD_Tab_ID,DisplayLength,IsSameLine,IsHeading,SeqNo,IsCentrallyMaintained,AD_Field_ID,IsReadOnly,Name,AD_Field_UU,IsDisplayed,IsFieldOnly,UpdatedBy,AD_Org_ID,CreatedBy,Updated,IsActive,IsDisplayedGrid,XPosition,IsQuickEntry,AD_Client_ID,ColumnSpan,NumLines,IsAdvancedField,IsDefaultFocus,AD_Column_ID,EntityType,Created) VALUES ('N',200142,36,'N','N',0,'Y',203026,'N','AD_InfoProcess_UU','87361dd1-cfc0-412d-a344-e5f602650e32','N','N',100,0,100,TO_TIMESTAMP('2014-05-26 22:31:48','YYYY-MM-DD HH24:MI:SS'),'Y','N',1,'N',0,2,1,'N','N',211242,'D',TO_TIMESTAMP('2014-05-26 22:31:48','YYYY-MM-DD HH24:MI:SS')) +; + +-- May 26, 2014 10:31:49 PM ICT +INSERT INTO AD_Field (IsEncrypted,AD_Tab_ID,DisplayLength,IsSameLine,IsHeading,SeqNo,IsCentrallyMaintained,AD_Field_ID,IsReadOnly,Name,AD_Field_UU,IsDisplayed,IsFieldOnly,UpdatedBy,AD_Org_ID,CreatedBy,Updated,IsActive,IsDisplayedGrid,XPosition,IsQuickEntry,AD_Client_ID,ColumnSpan,NumLines,IsAdvancedField,IsDefaultFocus,AD_Column_ID,EntityType,Created) VALUES ('N',200142,10,'N','N',0,'Y',203027,'N','Info Process','8020c77c-816a-4be9-a38c-747aed3afcf2','N','N',100,0,100,TO_TIMESTAMP('2014-05-26 22:31:49','YYYY-MM-DD HH24:MI:SS'),'Y','N',1,'N',0,2,1,'N','N',211241,'D',TO_TIMESTAMP('2014-05-26 22:31:49','YYYY-MM-DD HH24:MI:SS')) +; + +-- May 26, 2014 10:31:50 PM ICT +INSERT INTO AD_Field (IsEncrypted,AD_Tab_ID,DisplayLength,IsSameLine,IsHeading,SeqNo,IsCentrallyMaintained,AD_Field_ID,IsReadOnly,Help,Description,Name,AD_Field_UU,IsDisplayed,IsFieldOnly,UpdatedBy,AD_Org_ID,CreatedBy,Updated,IsActive,IsDisplayedGrid,XPosition,IsQuickEntry,AD_Client_ID,ColumnSpan,NumLines,IsAdvancedField,IsDefaultFocus,AD_Column_ID,EntityType,Created) VALUES ('N',200142,10,'N','N',10,'Y',203028,'Y','A Client is a company or a legal entity. You cannot share data between Clients. Tenant is a synonym for Client.','Client/Tenant for this installation.','Client','a6fccb4a-2521-4369-a1bb-06602ae9c840','Y','N',100,0,100,TO_TIMESTAMP('2014-05-26 22:31:49','YYYY-MM-DD HH24:MI:SS'),'Y','N',1,'N',0,2,1,'N','N',211243,'D',TO_TIMESTAMP('2014-05-26 22:31:49','YYYY-MM-DD HH24:MI:SS')) +; + +-- May 26, 2014 10:31:51 PM ICT +INSERT INTO AD_Field (IsEncrypted,AD_Tab_ID,DisplayLength,IsSameLine,IsHeading,SeqNo,IsCentrallyMaintained,AD_Field_ID,IsReadOnly,Help,Description,Name,AD_Field_UU,IsDisplayed,IsFieldOnly,IsAllowCopy,UpdatedBy,AD_Org_ID,CreatedBy,Updated,IsActive,IsDisplayedGrid,XPosition,IsQuickEntry,AD_Client_ID,ColumnSpan,NumLines,IsAdvancedField,IsDefaultFocus,AD_Column_ID,EntityType,Created) VALUES ('N',200142,10,'N','N',20,'Y',203029,'Y','An organization is a unit of your client or legal entity - examples are store, department. You can share data between organizations.','Organizational entity within client','Organization','60f9d173-cefb-417c-8080-8bb16aebff7e','Y','N','Y',100,0,100,TO_TIMESTAMP('2014-05-26 22:31:50','YYYY-MM-DD HH24:MI:SS'),'Y','N',4,'N',0,2,1,'N','N',211244,'D',TO_TIMESTAMP('2014-05-26 22:31:50','YYYY-MM-DD HH24:MI:SS')) +; + +-- May 26, 2014 10:31:51 PM ICT +INSERT INTO AD_Field (IsEncrypted,AD_Tab_ID,DisplayLength,IsSameLine,IsHeading,SeqNo,IsCentrallyMaintained,AD_Field_ID,IsReadOnly,Help,Description,Name,AD_Field_UU,IsDisplayed,IsFieldOnly,UpdatedBy,AD_Org_ID,CreatedBy,Updated,IsActive,IsDisplayedGrid,SeqNoGrid,XPosition,IsQuickEntry,AD_Client_ID,ColumnSpan,NumLines,IsAdvancedField,IsDefaultFocus,AD_Column_ID,EntityType,Created) VALUES ('N',200142,10,'N','N',30,'Y',203030,'Y','The Info window is used to search and select records as well as display information relevant to the selection.','Info and search/select Window','Info Window','ecc17f1a-a61e-4449-a35b-9915088cad60','Y','N',100,0,100,TO_TIMESTAMP('2014-05-26 22:31:51','YYYY-MM-DD HH24:MI:SS'),'Y','Y',60,1,'N',0,2,1,'N','N',211255,'D',TO_TIMESTAMP('2014-05-26 22:31:51','YYYY-MM-DD HH24:MI:SS')) +; + +-- May 26, 2014 10:31:52 PM ICT +INSERT INTO AD_Field (IsEncrypted,AD_Tab_ID,DisplayLength,IsSameLine,IsHeading,SeqNo,IsCentrallyMaintained,AD_Field_ID,IsReadOnly,Help,Description,Name,AD_Field_UU,IsDisplayed,IsFieldOnly,UpdatedBy,AD_Org_ID,CreatedBy,Updated,IsActive,IsDisplayedGrid,SeqNoGrid,XPosition,IsQuickEntry,AD_Client_ID,ColumnSpan,NumLines,IsAdvancedField,IsDefaultFocus,AD_Column_ID,EntityType,Created) VALUES ('N',200142,120,'N','N',40,'Y',203031,'N','URL of image; The image is not stored in the database, but retrieved at runtime. The image can be a gif, jpeg or png.','URL of image','Image URL','8a9c636e-677b-464c-a942-3e0e8f5ad3a4','Y','N',100,0,100,TO_TIMESTAMP('2014-05-26 22:31:51','YYYY-MM-DD HH24:MI:SS'),'Y','Y',30,4,'N',0,2,1,'N','N',211252,'D',TO_TIMESTAMP('2014-05-26 22:31:51','YYYY-MM-DD HH24:MI:SS')) +; + +-- May 26, 2014 10:31:53 PM ICT +INSERT INTO AD_Field (IsEncrypted,AD_Tab_ID,DisplayLength,IsSameLine,IsHeading,SeqNo,IsCentrallyMaintained,AD_Field_ID,IsReadOnly,Help,Description,Name,AD_Field_UU,IsDisplayed,IsFieldOnly,UpdatedBy,AD_Org_ID,CreatedBy,Updated,IsActive,IsDisplayedGrid,SeqNoGrid,XPosition,IsQuickEntry,AD_Client_ID,ColumnSpan,NumLines,IsAdvancedField,IsDefaultFocus,AD_Column_ID,EntityType,Created) VALUES ('N',200142,60,'N','N',50,'Y',203032,'N','The name of an entity (record) is used as an default search option in addition to the search key. The name is up to 60 characters in length.','Alphanumeric identifier of the entity','Name','af4c42ad-5b90-474a-80f4-41341a08d3cf','Y','N',100,0,100,TO_TIMESTAMP('2014-05-26 22:31:52','YYYY-MM-DD HH24:MI:SS'),'Y','Y',10,1,'N',0,5,1,'N','N',211250,'D',TO_TIMESTAMP('2014-05-26 22:31:52','YYYY-MM-DD HH24:MI:SS')) +; + +-- May 26, 2014 10:31:53 PM ICT +INSERT INTO AD_Field (IsEncrypted,AD_Tab_ID,DisplayLength,IsSameLine,IsHeading,SeqNo,IsCentrallyMaintained,AD_Field_ID,IsReadOnly,Help,Description,Name,AD_Field_UU,IsDisplayed,IsFieldOnly,UpdatedBy,AD_Org_ID,CreatedBy,Updated,IsActive,IsDisplayedGrid,SeqNoGrid,XPosition,IsQuickEntry,AD_Client_ID,ColumnSpan,NumLines,IsAdvancedField,IsDefaultFocus,AD_Column_ID,EntityType,Created) VALUES ('N',200142,255,'N','N',60,'Y',203033,'N','A description is limited to 255 characters.','Optional short description of the record','Description','cc49a78e-2927-484e-990e-8c303be44b4c','Y','N',100,0,100,TO_TIMESTAMP('2014-05-26 22:31:53','YYYY-MM-DD HH24:MI:SS'),'Y','Y',20,1,'N',0,5,1,'N','N',211251,'D',TO_TIMESTAMP('2014-05-26 22:31:53','YYYY-MM-DD HH24:MI:SS')) +; + +-- May 26, 2014 10:31:54 PM ICT +INSERT INTO AD_Field (SortNo,IsEncrypted,AD_Tab_ID,DisplayLength,IsSameLine,IsHeading,SeqNo,IsCentrallyMaintained,AD_Field_ID,IsReadOnly,Help,Description,Name,AD_Field_UU,IsDisplayed,IsFieldOnly,UpdatedBy,AD_Org_ID,CreatedBy,Updated,IsActive,IsDisplayedGrid,SeqNoGrid,XPosition,IsQuickEntry,AD_Client_ID,ColumnSpan,NumLines,IsAdvancedField,IsDefaultFocus,AD_Column_ID,EntityType,Created) VALUES (0,'N',200142,0,'N','N',70,'Y',203034,'N','The Help field contains a hint, comment or help about the use of this item.','Comment or Hint','Comment/Help','4b9118d1-4cc9-47fe-beee-b24e4d1263cb','Y','N',100,0,100,TO_TIMESTAMP('2014-05-26 22:31:53','YYYY-MM-DD HH24:MI:SS'),'Y','Y',80,1,'N',0,5,3,'N','N',211256,'D',TO_TIMESTAMP('2014-05-26 22:31:53','YYYY-MM-DD HH24:MI:SS')) +; + +-- May 26, 2014 10:31:55 PM ICT +INSERT INTO AD_Field (IsEncrypted,AD_Tab_ID,DisplayLength,IsSameLine,IsHeading,SeqNo,IsCentrallyMaintained,AD_Field_ID,IsReadOnly,Help,Description,Name,AD_Field_UU,IsDisplayed,IsFieldOnly,UpdatedBy,AD_Org_ID,CreatedBy,Updated,IsActive,IsDisplayedGrid,SeqNoGrid,XPosition,IsQuickEntry,AD_Client_ID,ColumnSpan,NumLines,IsAdvancedField,IsDefaultFocus,AD_Column_ID,EntityType,Created) VALUES ('N',200142,10,'N','N',80,'Y',203035,'N','The Process field identifies a unique Process or Report in the system.','Process or Report','Process','2f7cb5e4-1af9-4912-b9dd-bbc8ccbae537','Y','N',100,0,100,TO_TIMESTAMP('2014-05-26 22:31:54','YYYY-MM-DD HH24:MI:SS'),'Y','Y',50,1,'N',0,2,1,'N','N',211254,'D',TO_TIMESTAMP('2014-05-26 22:31:54','YYYY-MM-DD HH24:MI:SS')) +; + +-- May 26, 2014 10:31:55 PM ICT +INSERT INTO AD_Field (IsEncrypted,AD_Tab_ID,DisplayLength,IsSameLine,IsHeading,SeqNo,IsCentrallyMaintained,AD_Field_ID,IsReadOnly,Help,Description,Name,AD_Field_UU,IsDisplayed,IsFieldOnly,UpdatedBy,AD_Org_ID,CreatedBy,Updated,IsActive,IsDisplayedGrid,SeqNoGrid,XPosition,IsQuickEntry,AD_Client_ID,ColumnSpan,NumLines,IsAdvancedField,IsDefaultFocus,AD_Column_ID,EntityType,Created) VALUES ('N',200142,10,'N','N',90,'Y',203036,'N','The Sequence indicates the order of records','Method of ordering records; lowest number comes first','Sequence','c5ee4976-735e-40f8-8cd4-4bacc36adcdf','Y','N',100,0,100,TO_TIMESTAMP('2014-05-26 22:31:55','YYYY-MM-DD HH24:MI:SS'),'Y','Y',40,4,'N',0,2,1,'N','N',211253,'D',TO_TIMESTAMP('2014-05-26 22:31:55','YYYY-MM-DD HH24:MI:SS')) +; + +-- May 26, 2014 10:31:56 PM ICT +INSERT INTO AD_Field (SortNo,IsEncrypted,AD_Tab_ID,DisplayLength,IsSameLine,IsHeading,SeqNo,IsCentrallyMaintained,AD_Field_ID,IsReadOnly,Help,Description,Name,AD_Field_UU,IsDisplayed,IsFieldOnly,UpdatedBy,AD_Org_ID,CreatedBy,Updated,IsActive,IsDisplayedGrid,SeqNoGrid,XPosition,IsQuickEntry,AD_Client_ID,ColumnSpan,NumLines,IsAdvancedField,IsDefaultFocus,AD_Column_ID,EntityType,Created) VALUES (0,'N',200142,0,'N','N',100,'Y',203037,'N','Process info can display as button, list, menu','Layout type of info process','LayoutType','106b208d-b39b-4ab0-b839-7d0c95951bea','Y','N',100,0,100,TO_TIMESTAMP('2014-05-26 22:31:55','YYYY-MM-DD HH24:MI:SS'),'Y','Y',90,1,'N',0,2,1,'N','N',211257,'D',TO_TIMESTAMP('2014-05-26 22:31:55','YYYY-MM-DD HH24:MI:SS')) +; + +-- May 26, 2014 10:31:57 PM ICT +INSERT INTO AD_Field (IsEncrypted,AD_Tab_ID,DisplayLength,IsSameLine,IsHeading,SeqNo,IsCentrallyMaintained,AD_Field_ID,IsReadOnly,Help,Description,Name,AD_Field_UU,IsDisplayed,IsFieldOnly,UpdatedBy,AD_Org_ID,CreatedBy,Updated,IsActive,IsDisplayedGrid,SeqNoGrid,XPosition,IsQuickEntry,AD_Client_ID,ColumnSpan,NumLines,IsAdvancedField,IsDefaultFocus,AD_Column_ID,EntityType,Created) VALUES ('N',200142,1,'N','N',110,'Y',203038,'N','There are two methods of making records unavailable in the system: One is to delete the record, the other is to de-activate the record. A de-activated record is not available for selection, but available for reports. +There are two reasons for de-activating and not deleting records: +(1) The system requires the record for audit purposes. +(2) The record is referenced by other records. E.g., you cannot delete a Business Partner, if there are invoices for this partner record existing. You de-activate the Business Partner and prevent that this record is used for future entries.','The record is active in the system','Active','e45bfa22-f210-4a87-9b0c-b3ab2da35161','Y','N',100,0,100,TO_TIMESTAMP('2014-05-26 22:31:56','YYYY-MM-DD HH24:MI:SS'),'Y','Y',70,5,'N',0,2,1,'N','N',211245,'D',TO_TIMESTAMP('2014-05-26 22:31:56','YYYY-MM-DD HH24:MI:SS')) +; + +-- migrate for anyone use red1 process in info panel start +INSERT INTO AD_InfoProcess +(ad_infoprocess_id, ad_infowindow_id, ad_client_id, ad_org_id, isactive,createdby, updatedby, seqno, name, ad_process_id, description, help, ad_infoprocess_uu) +(SELECT nextidfunc(200176,'N'), ad_infowindow_id, iw.ad_client_id, iw.ad_org_id, 'Y', 100, 100, 10, pr.name, iw.ad_process_id, pr.description, pr.help, generate_uuid() +FROM ad_infowindow iw INNER JOIN ad_process pr ON pr.ad_process_ID = iw.ad_process_ID +WHERE iw.ad_process_ID IS NOT NULL +); + +-- May 23, 2014 4:01:30 PM ICT +DELETE FROM AD_Field_Trl WHERE AD_Field_ID=202596 +; + +-- May 23, 2014 4:01:30 PM ICT +DELETE FROM AD_Field WHERE AD_Field_ID=202596 +; + +-- May 23, 2014 4:01:51 PM ICT +UPDATE AD_Column SET IsActive='N' WHERE AD_Column_ID=210944 +; + +SELECT register_migration_script('201405261604_IDEMPIERE-1334.sql') FROM dual +; diff --git a/migration/i2.0z/postgresql/201405291604_IDEMPIERE-1334.sql b/migration/i2.0z/postgresql/201405291604_IDEMPIERE-1334.sql new file mode 100644 index 0000000000..8e6fb2c8b5 --- /dev/null +++ b/migration/i2.0z/postgresql/201405291604_IDEMPIERE-1334.sql @@ -0,0 +1,63 @@ +-- May 29, 2014 6:19:41 AM ICT +-- I forgot to set the DICTIONARY_ID_COMMENTS System Configurator +DELETE FROM AD_Field_Trl WHERE AD_Field_ID=203032 +; + +-- May 29, 2014 6:19:41 AM ICT +DELETE FROM AD_Field WHERE AD_Field_ID=203032 +; + +-- May 29, 2014 6:19:52 AM ICT +DELETE FROM AD_Field_Trl WHERE AD_Field_ID=203033 +; + +-- May 29, 2014 6:19:52 AM ICT +DELETE FROM AD_Field WHERE AD_Field_ID=203033 +; + +-- May 29, 2014 6:19:52 AM ICT +DELETE FROM AD_Field_Trl WHERE AD_Field_ID=203034 +; + +-- May 29, 2014 6:19:52 AM ICT +DELETE FROM AD_Field WHERE AD_Field_ID=203034 +; + +-- May 29, 2014 6:20:37 AM ICT +DELETE FROM AD_Column_Trl WHERE AD_Column_ID=211251 +; + +-- May 29, 2014 6:20:37 AM ICT +DELETE FROM AD_Column WHERE AD_Column_ID=211251 +; + +-- May 29, 2014 6:20:38 AM ICT +DELETE FROM AD_Column_Trl WHERE AD_Column_ID=211256 +; + +-- May 29, 2014 6:20:38 AM ICT +DELETE FROM AD_Column WHERE AD_Column_ID=211256 +; + +-- May 29, 2014 6:20:38 AM ICT +DELETE FROM AD_Column_Trl WHERE AD_Column_ID=211250 +; + +-- May 29, 2014 6:20:38 AM ICT +DELETE FROM AD_Column WHERE AD_Column_ID=211250 +; + +ALTER TABLE ad_infoprocess DROP COLUMN name +; + +ALTER TABLE ad_infoprocess DROP COLUMN description +; + +ALTER TABLE ad_infoprocess DROP COLUMN help +; + +-- May 29, 2014 6:21:41 AM ICT +INSERT INTO AD_Message (MsgType,MsgText,AD_Message_ID,EntityType,AD_Message_UU,Value,IsActive,Updated,CreatedBy,UpdatedBy,AD_Client_ID,AD_Org_ID,Created) VALUES ('M','Process Menu',200275,'D','c7cb8357-7a1f-46ab-9957-cda58431adfd','ProcessMenu','Y',TO_TIMESTAMP('2014-05-29 06:21:35','YYYY-MM-DD HH24:MI:SS'),100,100,0,0,TO_TIMESTAMP('2014-05-29 06:21:35','YYYY-MM-DD HH24:MI:SS')) +; +SELECT register_migration_script('201405291604_IDEMPIERE-1334.sql') FROM dual +; diff --git a/migration/i2.0z/postgresql/201405291802_IDEMPIERE-1334.sql b/migration/i2.0z/postgresql/201405291802_IDEMPIERE-1334.sql new file mode 100644 index 0000000000..68d21270ec --- /dev/null +++ b/migration/i2.0z/postgresql/201405291802_IDEMPIERE-1334.sql @@ -0,0 +1,32 @@ +-- May 29, 2014 6:00:45 PM COT +-- I forgot to set the DICTIONARY_ID_COMMENTS System Configurator +UPDATE AD_Column SET IsIdentifier='Y', SeqNo=1,Updated=TO_TIMESTAMP('2014-05-29 18:00:45','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=211254 +; + +-- May 29, 2014 6:02:16 PM COT +UPDATE AD_Field SET SeqNoGrid=0,IsDisplayedGrid='N' WHERE AD_Field_ID=203030 +; + +-- May 29, 2014 6:02:16 PM COT +UPDATE AD_Field SET SeqNoGrid=10,IsDisplayedGrid='Y' WHERE AD_Field_ID=203036 +; + +-- May 29, 2014 6:02:16 PM COT +UPDATE AD_Field SET SeqNoGrid=20,IsDisplayedGrid='Y' WHERE AD_Field_ID=203035 +; + +-- May 29, 2014 6:02:16 PM COT +UPDATE AD_Field SET SeqNoGrid=30,IsDisplayedGrid='Y' WHERE AD_Field_ID=203037 +; + +-- May 29, 2014 6:02:16 PM COT +UPDATE AD_Field SET SeqNoGrid=40,IsDisplayedGrid='Y' WHERE AD_Field_ID=203038 +; + +-- May 29, 2014 6:02:16 PM COT +UPDATE AD_Field SET SeqNoGrid=50,IsDisplayedGrid='Y' WHERE AD_Field_ID=203031 +; + +SELECT register_migration_script('201405291802_IDEMPIERE-1334.sql') FROM dual +; + diff --git a/migration/i2.0z/postgresql/201405301104_IDEMPIERE-1856.sql b/migration/i2.0z/postgresql/201405301104_IDEMPIERE-1856.sql new file mode 100644 index 0000000000..5b5850aa8d --- /dev/null +++ b/migration/i2.0z/postgresql/201405301104_IDEMPIERE-1856.sql @@ -0,0 +1,86 @@ +CREATE OR REPLACE FUNCTION invoiceDiscount +( + p_C_Invoice_ID NUMERIC, + p_paydate timestamp with time zone, + p_C_InvoicePaySchedule_ID NUMERIC +) +RETURNS numeric AS $body$ +/************************************************************************* + * The contents of this file are subject to the Compiere License. You may + * obtain a copy of the License at http://www.compiere.org/license.html + * Software is on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either + * express or implied. See the License for details. Code: Compiere ERP+CRM + * Copyright (C) 1999-2001 Jorg Janke, ComPiere, Inc. All Rights Reserved. + * + * converted to postgreSQL by Karsten Thiemann (Schaeffer AG), + * kthiemann@adempiere.org + ************************************************************************* + *** + * Title: Calculate Payment Discount Amount + * Description: + * - Calculate discountable amount (i.e. with or without tax) + * - Calculate and return payment discount + * Test: + * select invoiceDiscount(109, now(), 103) from ad_system; => 0 + ************************************************************************/ +DECLARE + v_Amount NUMERIC; + v_IsDiscountLineAmt CHAR(1); + v_GrandTotal NUMERIC; + v_TotalLines NUMERIC; + v_C_PaymentTerm_ID NUMERIC(10); + v_C_Currency_ID NUMERIC(10); + v_DocDate timestamp with time zone; + v_PayDate timestamp with time zone := now(); + v_IsPayScheduleValid CHAR(1); + +BEGIN + SELECT ci.IsDiscountLineAmt, i.GrandTotal, i.TotalLines, + i.C_PaymentTerm_ID, i.DateInvoiced, i.IsPayScheduleValid, C_Currency_ID + INTO v_IsDiscountLineAmt, v_GrandTotal, v_TotalLines, + v_C_PaymentTerm_ID, v_DocDate, v_IsPayScheduleValid, v_C_Currency_ID + FROM AD_ClientInfo ci, C_Invoice i + WHERE ci.AD_Client_ID=i.AD_Client_ID + AND i.C_Invoice_ID=p_C_Invoice_ID; + + -- What Amount is the Discount Base? + IF (v_IsDiscountLineAmt = 'Y') THEN + v_Amount := v_TotalLines; + ELSE + v_Amount := v_GrandTotal; + END IF; + + -- Anything to discount? + IF (v_Amount = 0) THEN + RETURN 0; + END IF; + IF (p_PayDate IS NOT NULL) THEN + v_PayDate := p_PayDate; + END IF; + + -- Valid Payment Schedule + IF (v_IsPayScheduleValid='Y' AND p_C_InvoicePaySchedule_ID > 0) THEN + SELECT COALESCE(MAX(DiscountAmt),0) + INTO v_Amount + FROM C_InvoicePaySchedule + WHERE C_InvoicePaySchedule_ID=p_C_InvoicePaySchedule_ID + AND DiscountDate <= v_PayDate; + -- + RETURN v_Amount; + END IF; + + -- return discount amount + RETURN paymentTermDiscount (v_Amount, v_C_Currency_ID, v_C_PaymentTerm_ID, v_DocDate, p_PayDate); + +-- Most likely if invoice not found +EXCEPTION + WHEN OTHERS THEN + RETURN NULL; +END; + +$body$ LANGUAGE plpgsql; + + +SELECT register_migration_script('201405301104_IDEMPIERE-1856.sql') FROM dual +; + diff --git a/migration/i2.0z/postgresql/201405301149_IDEMPIERE-1953.sql b/migration/i2.0z/postgresql/201405301149_IDEMPIERE-1953.sql new file mode 100644 index 0000000000..ea075879b0 --- /dev/null +++ b/migration/i2.0z/postgresql/201405301149_IDEMPIERE-1953.sql @@ -0,0 +1,2128 @@ +-- IDEMPIERE-1953 Performance problem of postgresql functions - adding STABLE/IMMUTABLE attribute. + +CREATE OR REPLACE FUNCTION acctBalance(p_Account_ID numeric, p_AmtDr numeric, p_AmtCr numeric) RETURNS numeric AS $body$ +DECLARE + v_balance NUMERIC; + v_AccountType C_ElementValue.AccountType%TYPE; + v_AccountSign C_ElementValue.AccountSign%TYPE; + +BEGIN + v_balance := p_AmtDr - p_AmtCr; + -- + IF (p_Account_ID > 0) THEN + SELECT AccountType, AccountSign + INTO v_AccountType, v_AccountSign + FROM C_ElementValue + WHERE C_ElementValue_ID=p_Account_ID; + -- DBMS_OUTPUT.PUT_LINE('Type=' || v_AccountType || ' - Sign=' || v_AccountSign); + -- Natural Account Sign + IF (v_AccountSign='N') THEN + IF (v_AccountType IN ('A','E')) THEN + v_AccountSign := 'D'; + ELSE + v_AccountSign := 'C'; + END IF; + -- DBMS_OUTPUT.PUT_LINE('Type=' || v_AccountType || ' - Sign=' || v_AccountSign); + END IF; + -- Debit Balance + IF (v_AccountSign = 'C') THEN + v_balance := p_AmtCr - p_AmtDr; + END IF; + END IF; + -- + RETURN v_balance; + EXCEPTION WHEN OTHERS THEN + -- In case Acct not found + RETURN p_AmtDr - p_AmtCr; + +END; + +$body$ LANGUAGE plpgsql STABLE; + +CREATE OR REPLACE FUNCTION add_months (in datetime timestamptz, in months numeric) RETURNS date AS +$BODY$ +declare duration varchar; +BEGIN + if datetime is null or months is null then + return null; + end if; + duration = months || ' month'; + return cast(datetime + cast(duration as interval) as date); +END; +$BODY$ +LANGUAGE 'plpgsql' IMMUTABLE +; + +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 STABLE; + +create or replace FUNCTION currencyBase +( + p_Amount NUMERIC, + p_CurFrom_ID NUMERIC, + p_ConvDate timestamp with time zone, + p_Client_ID NUMERIC, + p_Org_ID NUMERIC +) +RETURNS numeric AS $body$ +/************************************************************************* + * The contents of this file are subject to the Compiere License. You may + * obtain a copy of the License at http://www.compiere.org/license.html + * Software is on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either + * express or implied. See the License for details. Code: Compiere ERP+CRM + * Copyright (C) 1999-2001 Jorg Janke, ComPiere, Inc. All Rights Reserved. + * + * converted to postgreSQL by Karsten Thiemann (Schaeffer AG), + * kthiemann@adempiere.org + ************************************************************************* + * + *** + * Title: Convert Amount to Base Currency of Client + * Description: + * Get CurrencyTo from Client + * Returns NULL, if conversion not found + * Standard Rounding + * Test: + * SELECT currencyBase(100,116,null,11,null) FROM AD_System; => 64.72 + ************************************************************************/ +DECLARE + v_CurTo_ID NUMERIC; +BEGIN + -- Get Currency + SELECT MAX(ac.C_Currency_ID) + INTO v_CurTo_ID + FROM AD_ClientInfo ci, C_AcctSchema ac + WHERE ci.C_AcctSchema1_ID=ac.C_AcctSchema_ID + AND ci.AD_Client_ID=p_Client_ID; + -- Same as Currency_Conversion - if currency/rate not found - return 0 + IF (v_CurTo_ID IS NULL) THEN + RETURN NULL; + END IF; + -- Same currency + IF (p_CurFrom_ID = v_CurTo_ID) THEN + RETURN p_Amount; + END IF; + + RETURN currencyConvert (p_Amount, p_CurFrom_ID, v_CurTo_ID, p_ConvDate, null, p_Client_ID, p_Org_ID); +END; + +$body$ LANGUAGE plpgsql STABLE; + +CREATE OR REPLACE FUNCTION currencyConvert( + p_Amount NUMERIC, + p_CurFrom_ID NUMERIC, + p_CurTo_ID NUMERIC, + p_ConvDate timestamp with time zone, + p_ConversionType_ID IN NUMERIC, + p_Client_ID NUMERIC, + p_Org_ID NUMERIC + ) + +RETURNS numeric AS $body$ + +/************************************************************************* + * The contents of this file are subject to the Compiere License. You may + * obtain a copy of the License at http://www.compiere.org/license.html + * Software is on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either + * express or implied. See the License for details. Code: Compiere ERP+CRM + * Copyright (C) 1999-2001 Jorg Janke, ComPiere, Inc. All Rights Reserved. + * + * converted to postgreSQL by Karsten Thiemann (Schaeffer AG), + * kthiemann@adempiere.org + ************************************************************************* + *** + * Title: Convert Amount (using IDs) + * Description: + * from CurrencyFrom_ID to CurrencyTo_ID + * Returns NULL, if conversion not found + * Standard Rounding + * Test: + * SELECT currencyConvert(100,116,100,null,null,null,null) FROM AD_System; => 64.72 + ************************************************************************/ + + +DECLARE + v_Rate NUMERIC; + +BEGIN + -- Return Amount + IF (p_Amount = 0 OR p_CurFrom_ID = p_CurTo_ID) THEN + RETURN p_Amount; + END IF; + -- Return NULL + IF (p_Amount IS NULL OR p_CurFrom_ID IS NULL OR p_CurTo_ID IS NULL) THEN + RETURN NULL; + END IF; + + -- Get Rate + v_Rate := currencyRate (p_CurFrom_ID, p_CurTo_ID, p_ConvDate, p_ConversionType_ID, p_Client_ID, p_Org_ID); + IF (v_Rate IS NULL) THEN + RETURN NULL; + END IF; + + -- Standard Precision + RETURN currencyRound(p_Amount * v_Rate, p_CurTo_ID, null); + +END; + +$body$ LANGUAGE plpgsql STABLE; + +CREATE OR REPLACE FUNCTION currencyRate( + p_CurFrom_ID NUMERIC, + p_CurTo_ID NUMERIC, + p_ConvDate timestamp with time zone, + p_ConversionType_ID NUMERIC, + p_Client_ID NUMERIC, + p_Org_ID NUMERIC + ) + +RETURNS numeric AS $body$ + +/************************************************************************* + * The contents of this file are subject to the Compiere License. You may + * obtain a copy of the License at http://www.compiere.org/license.html + * Software is on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either + * express or implied. See the License for details. Code: Compiere ERP+CRM + * Copyright (C) 1999-2001 Jorg Janke, ComPiere, Inc. All Rights Reserved. + * + * converted to postgreSQL by Karsten Thiemann (Schaeffer AG), + * kthiemann@adempiere.org + ************************************************************************* + *** + * Title: Return Conversion Rate + * Description: + * from CurrencyFrom_ID to CurrencyTo_ID + * Returns NULL, if rate not found + * Test + * SELECT currencyrate(116, 100, null, null, null, null) FROM AD_System; => .647169 + ************************************************************************/ + + +DECLARE + -- Currency From variables + cf_IsEuro CHAR(1); + cf_IsEMUMember CHAR(1); + cf_EMUEntryDate timestamp with time zone; + cf_EMURate NUMERIC; + -- Currency To variables + ct_IsEuro CHAR(1); + ct_IsEMUMember CHAR(1); + ct_EMUEntryDate DATE; + ct_EMURate NUMERIC; + -- Triangle + v_CurrencyFrom NUMERIC; + v_CurrencyTo NUMERIC; + v_CurrencyEuro NUMERIC; + -- + v_ConvDate timestamp with time zone := now(); + v_ConversionType_ID NUMERIC := 0; + v_Rate NUMERIC; + c RECORD; + +BEGIN +-- No Conversion + IF (p_CurFrom_ID = p_CurTo_ID) THEN + RETURN 1; + END IF; + -- Default Date Parameter + IF (p_ConvDate IS NOT NULL) THEN + v_ConvDate := p_ConvDate; -- SysDate + END IF; + -- Default Conversion Type + IF (p_ConversionType_ID IS NULL OR p_ConversionType_ID = 0) THEN + BEGIN + SELECT C_ConversionType_ID + INTO v_ConversionType_ID + FROM C_ConversionType + WHERE IsDefault='Y' + AND AD_Client_ID IN (0,p_Client_ID) + ORDER BY AD_Client_ID DESC + LIMIT 1; + EXCEPTION WHEN OTHERS THEN + RAISE NOTICE 'Conversion Type Not Found'; + END; + ELSE + v_ConversionType_ID := p_ConversionType_ID; + END IF; + + -- Get Currency Info + SELECT MAX(IsEuro), MAX(IsEMUMember), MAX(EMUEntryDate), MAX(EMURate) + INTO cf_IsEuro, cf_IsEMUMember, cf_EMUEntryDate, cf_EMURate + FROM C_Currency + WHERE C_Currency_ID = p_CurFrom_ID; + -- Not Found + IF (cf_IsEuro IS NULL) THEN + RAISE NOTICE 'From Currency Not Found'; + RETURN NULL; + END IF; + SELECT MAX(IsEuro), MAX(IsEMUMember), MAX(EMUEntryDate), MAX(EMURate) + INTO ct_IsEuro, ct_IsEMUMember, ct_EMUEntryDate, ct_EMURate + FROM C_Currency + WHERE C_Currency_ID = p_CurTo_ID; + -- Not Found + IF (ct_IsEuro IS NULL) THEN + RAISE NOTICE 'To Currency Not Found'; + RETURN NULL; + END IF; + + -- Fixed - From Euro to EMU + IF (cf_IsEuro = 'Y' AND ct_IsEMUMember ='Y' AND v_ConvDate >= ct_EMUEntryDate) THEN + RETURN ct_EMURate; + END IF; + + -- Fixed - From EMU to Euro + IF (ct_IsEuro = 'Y' AND cf_IsEMUMember ='Y' AND v_ConvDate >= cf_EMUEntryDate) THEN + RETURN 1 / cf_EMURate; + END IF; + + -- Fixed - From EMU to EMU + IF (cf_IsEMUMember = 'Y' AND cf_IsEMUMember ='Y' + AND v_ConvDate >= cf_EMUEntryDate AND v_ConvDate >= ct_EMUEntryDate) THEN + RETURN ct_EMURate / cf_EMURate; + END IF; + + -- Flexible Rates + v_CurrencyFrom := p_CurFrom_ID; + v_CurrencyTo := p_CurTo_ID; + + -- if EMU Member involved, replace From/To Currency + IF ((cf_isEMUMember = 'Y' AND v_ConvDate >= cf_EMUEntryDate) + OR (ct_isEMUMember = 'Y' AND v_ConvDate >= ct_EMUEntryDate)) THEN + SELECT MAX(C_Currency_ID) + INTO v_CurrencyEuro + FROM C_Currency + WHERE IsEuro = 'Y'; + -- Conversion Rate not Found + IF (v_CurrencyEuro IS NULL) THEN + RAISE NOTICE 'Euro Not Found'; + RETURN NULL; + END IF; + IF (cf_isEMUMember = 'Y' AND v_ConvDate >= cf_EMUEntryDate) THEN + v_CurrencyFrom := v_CurrencyEuro; + ELSE + v_CurrencyTo := v_CurrencyEuro; + END IF; + END IF; + + -- Get Rate + + BEGIN + FOR c IN SELECT MultiplyRate + FROM C_Conversion_Rate + WHERE C_Currency_ID=v_CurrencyFrom AND C_Currency_ID_To=v_CurrencyTo + AND C_ConversionType_ID=v_ConversionType_ID + AND v_ConvDate BETWEEN ValidFrom AND ValidTo + AND AD_Client_ID IN (0,p_Client_ID) AND AD_Org_ID IN (0,p_Org_ID) + ORDER BY AD_Client_ID DESC, AD_Org_ID DESC, ValidFrom DESC + LOOP + v_Rate := c.MultiplyRate; + EXIT; -- only first + END LOOP; + END; + -- Not found + IF (v_Rate IS NULL) THEN + RAISE NOTICE 'Conversion Rate Not Found'; + RETURN NULL; + END IF; + + -- Currency From was EMU + IF (cf_isEMUMember = 'Y' AND v_ConvDate >= cf_EMUEntryDate) THEN + RETURN v_Rate / cf_EMURate; + END IF; + + -- Currency To was EMU + IF (ct_isEMUMember = 'Y' AND v_ConvDate >= ct_EMUEntryDate) THEN + RETURN v_Rate * ct_EMURate; + END IF; + + RETURN v_Rate; + +EXCEPTION WHEN OTHERS THEN + RAISE NOTICE '%', SQLERRM; + RETURN NULL; + + +END; + +$body$ LANGUAGE plpgsql STABLE; + +-- DROP FUNCTION currencyround(p_amount numeric, p_curto_id numeric, p_costing character varying); + +CREATE OR REPLACE FUNCTION currencyRound( + p_Amount NUMERIC, + p_CurTo_ID NUMERIC, + p_Costing character varying -- Default 'N' +) + +RETURNS numeric AS $BODY$ + +/************************************************************************* + * The contents of this file are subject to the Compiere License. You may + * obtain a copy of the License at http://www.compiere.org/license.html + * Software is on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either + * express or implied. See the License for details. Code: Compiere ERP+CRM + * Copyright (C) 1999-2001 Jorg Janke, ComPiere, Inc. All Rights Reserved. + * + * converted to postgreSQL by Karsten Thiemann (Schaeffer AG), + * kthiemann@adempiere.org + ************************************************************************* + *** + * Title: Round amount for Traget Currency + * Description: + * Round Amount using Costing or Standard Precision + * Returns unmodified amount if currency not found + * Test: + * SELECT currencyRound(currencyConvert(100,116,100,null,null),100,null) FROM AD_System => 64.72 + ************************************************************************/ + + +DECLARE + v_StdPrecision int; + v_CostPrecision int; + +BEGIN + -- Nothing to convert + IF (p_Amount IS NULL OR p_CurTo_ID IS NULL) THEN + RETURN p_Amount; + END IF; + + -- Ger Precision + SELECT MAX(StdPrecision), MAX(CostingPrecision) + INTO v_StdPrecision, v_CostPrecision + FROM C_Currency + WHERE C_Currency_ID = p_CurTo_ID; + -- Currency Not Found + IF (v_StdPrecision IS NULL) THEN + RETURN p_Amount; + END IF; + + IF (p_Costing = 'Y') THEN + RETURN ROUND (p_Amount, v_CostPrecision); + END IF; + + RETURN ROUND (p_Amount, v_StdPrecision); + +END; + +$BODY$ + LANGUAGE 'plpgsql' STABLE; + +CREATE OR REPLACE FUNCTION invoiceDiscount +( + p_C_Invoice_ID NUMERIC, + p_paydate timestamp with time zone, + p_C_InvoicePaySchedule_ID NUMERIC +) +RETURNS numeric AS $body$ +/************************************************************************* + * The contents of this file are subject to the Compiere License. You may + * obtain a copy of the License at http://www.compiere.org/license.html + * Software is on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either + * express or implied. See the License for details. Code: Compiere ERP+CRM + * Copyright (C) 1999-2001 Jorg Janke, ComPiere, Inc. All Rights Reserved. + * + * converted to postgreSQL by Karsten Thiemann (Schaeffer AG), + * kthiemann@adempiere.org + ************************************************************************* + *** + * Title: Calculate Payment Discount Amount + * Description: + * - Calculate discountable amount (i.e. with or without tax) + * - Calculate and return payment discount + * Test: + * select invoiceDiscount(109, now(), 103) from ad_system; => 0 + ************************************************************************/ +DECLARE + v_Amount NUMERIC; + v_IsDiscountLineAmt CHAR(1); + v_GrandTotal NUMERIC; + v_TotalLines NUMERIC; + v_C_PaymentTerm_ID NUMERIC(10); + v_C_Currency_ID NUMERIC(10); + v_DocDate timestamp with time zone; + v_PayDate timestamp with time zone := now(); + v_IsPayScheduleValid CHAR(1); + +BEGIN + SELECT ci.IsDiscountLineAmt, i.GrandTotal, i.TotalLines, + i.C_PaymentTerm_ID, i.DateInvoiced, i.IsPayScheduleValid, C_Currency_ID + INTO v_IsDiscountLineAmt, v_GrandTotal, v_TotalLines, + v_C_PaymentTerm_ID, v_DocDate, v_IsPayScheduleValid, v_C_Currency_ID + FROM AD_ClientInfo ci, C_Invoice i + WHERE ci.AD_Client_ID=i.AD_Client_ID + AND i.C_Invoice_ID=p_C_Invoice_ID; + + -- What Amount is the Discount Base? + IF (v_IsDiscountLineAmt = 'Y') THEN + v_Amount := v_TotalLines; + ELSE + v_Amount := v_GrandTotal; + END IF; + + -- Anything to discount? + IF (v_Amount = 0) THEN + RETURN 0; + END IF; + IF (p_PayDate IS NOT NULL) THEN + v_PayDate := p_PayDate; + END IF; + + -- Valid Payment Schedule + IF (v_IsPayScheduleValid='Y' AND p_C_InvoicePaySchedule_ID > 0) THEN + SELECT COALESCE(MAX(DiscountAmt),0) + INTO v_Amount + FROM C_InvoicePaySchedule + WHERE C_InvoicePaySchedule_ID=p_C_InvoicePaySchedule_ID + AND DiscountDate <= v_PayDate; + -- + RETURN v_Amount; + END IF; + + -- return discount amount + RETURN paymentTermDiscount (v_Amount, v_C_Currency_ID, v_C_PaymentTerm_ID, v_DocDate, p_PayDate); + +-- Most likely if invoice not found +EXCEPTION + WHEN OTHERS THEN + RETURN NULL; +END; + +$body$ LANGUAGE plpgsql STABLE; + +CREATE OR REPLACE FUNCTION invoiceopen (in p_c_invoice_id numeric, in p_c_invoicepayschedule_id numeric) RETURNS numeric AS +$BODY$ +/************************************************************************* + * The contents of this file are subject to the Compiere License. You may + * obtain a copy of the License at http://www.compiere.org/license.html + * Software is on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either + * express or implied. See the License for details. Code: Compiere ERP+CRM + * Copyright (C) 1999-2001 Jorg Janke, ComPiere, Inc. All Rights Reserved. + * + * converted to postgreSQL by Karsten Thiemann (Schaeffer AG), + * kthiemann@adempiere.org + ************************************************************************* + *** + * Title: Calculate Open Item Amount in Invoice Currency + * Description: + * Add up total amount open for C_Invoice_ID if no split payment. + * Grand Total minus Sum of Allocations in Invoice Currency + * + * For Split Payments: + * Allocate Payments starting from first schedule. + * Cannot be used for IsPaid as mutating + * + * Test: + * SELECT C_InvoicePaySchedule_ID, DueAmt FROM C_InvoicePaySchedule WHERE C_Invoice_ID=109 ORDER BY DueDate; + * SELECT invoiceOpen (109, null) FROM AD_System; - converted to default client currency + * SELECT invoiceOpen (109, 11) FROM AD_System; - converted to default client currency + * SELECT invoiceOpen (109, 102) FROM AD_System; + * SELECT invoiceOpen (109, 103) FROM AD_System; + ************************************************************************/ +DECLARE + v_Currency_ID NUMERIC(10); + v_TotalOpenAmt NUMERIC := 0; + v_PaidAmt NUMERIC := 0; + v_Remaining NUMERIC := 0; + v_MultiplierAP NUMERIC := 0; + v_MultiplierCM NUMERIC := 0; + v_Temp NUMERIC := 0; + v_Precision NUMERIC := 0; + v_Min NUMERIC := 0; + ar RECORD; + s RECORD; + +BEGIN + -- Get Currency + BEGIN + SELECT MAX(C_Currency_ID), SUM(GrandTotal), MAX(MultiplierAP), MAX(Multiplier) + INTO v_Currency_ID, v_TotalOpenAmt, v_MultiplierAP, v_MultiplierCM + FROM C_Invoice_v -- corrected for CM / Split Payment + WHERE C_Invoice_ID = p_C_Invoice_ID; + EXCEPTION -- Invoice in draft form + WHEN OTHERS THEN + RAISE NOTICE 'InvoiceOpen - %', SQLERRM; + RETURN NULL; + END; + + SELECT StdPrecision + INTO v_Precision + FROM C_Currency + WHERE C_Currency_ID = v_Currency_ID; + + SELECT 1/10^v_Precision INTO v_Min; + + -- Calculate Allocated Amount + FOR ar IN + SELECT a.AD_Client_ID, a.AD_Org_ID, + al.Amount, al.DiscountAmt, al.WriteOffAmt, + a.C_Currency_ID, a.DateTrx + FROM C_AllocationLine al + INNER JOIN C_AllocationHdr a ON (al.C_AllocationHdr_ID=a.C_AllocationHdr_ID) + WHERE al.C_Invoice_ID = p_C_Invoice_ID + AND a.IsActive='Y' + LOOP + v_Temp := ar.Amount + ar.DisCountAmt + ar.WriteOffAmt; + v_PaidAmt := v_PaidAmt + -- Allocation + + currencyConvert(v_Temp * v_MultiplierAP, + ar.C_Currency_ID, v_Currency_ID, ar.DateTrx, null, ar.AD_Client_ID, ar.AD_Org_ID); + RAISE NOTICE ' PaidAmt=% , Allocation= % * %', v_PaidAmt, v_Temp, v_MultiplierAP; + END LOOP; + + -- Do we have a Payment Schedule ? + IF (p_C_InvoicePaySchedule_ID > 0) THEN -- if not valid = lists invoice amount + v_Remaining := v_PaidAmt; + FOR s IN + SELECT C_InvoicePaySchedule_ID, DueAmt + FROM C_InvoicePaySchedule + WHERE C_Invoice_ID = p_C_Invoice_ID + AND IsValid='Y' + ORDER BY DueDate + LOOP + IF (s.C_InvoicePaySchedule_ID = p_C_InvoicePaySchedule_ID) THEN + v_TotalOpenAmt := (s.DueAmt*v_MultiplierCM) - v_Remaining; + IF (s.DueAmt - v_Remaining < 0) THEN + v_TotalOpenAmt := 0; + END IF; + ELSE -- calculate amount, which can be allocated to next schedule + v_Remaining := v_Remaining - s.DueAmt; + IF (v_Remaining < 0) THEN + v_Remaining := 0; + END IF; + END IF; + END LOOP; + ELSE + v_TotalOpenAmt := v_TotalOpenAmt - v_PaidAmt; + END IF; +-- RAISE NOTICE ''== Total='' || v_TotalOpenAmt; + + -- Ignore Rounding + IF (v_TotalOpenAmt > -v_Min AND v_TotalOpenAmt < v_Min) THEN + v_TotalOpenAmt := 0; + END IF; + + -- Round to currency precision + v_TotalOpenAmt := ROUND(COALESCE(v_TotalOpenAmt,0), v_Precision); + RETURN v_TotalOpenAmt; +END; + +$BODY$ +LANGUAGE 'plpgsql' STABLE +; + +/* + *This file is part of Adempiere ERP Bazaar + *http://www.adempiere.org + *Copyright (C) 2006-2008 victor.perez@e-evolution.com, e-Evolution + *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 + * Title: Calculate Open Item Amount in Invoice Currency + * Description: + * Add up total amount open for C_Invoice_ID if no split payment. + * Grand Total minus Sum of Allocations in Invoice Currency + * + * For Split Payments: + * Allocate Payments starting from first schedule. + +SELECT C_Invoice_Open (109) FROM DUAL; +SELECT C_Invoice_Open (109, null) FROM DUAL; +SELECT C_Invoice_Open (109, 11) FROM DUAL; +SELECT C_Invoice_Open (109, 102) FROM DUAL; +SELECT C_Invoice_Open (109, 103) FROM DUAL; +SELECT * FROM RV_OpenItem WHERE C_Invoice_ID=109; +SELECT C_InvoicePaySchedule_ID, DueAmt FROM C_InvoicePaySchedule WHERE C_Invoice_ID=109 ORDER BY DueDate; + +* Cannot be used for IsPaid as mutating +************************************************************************/ +CREATE OR REPLACE FUNCTION InvoiceopenToDate +( + p_C_Invoice_ID IN numeric, + p_C_InvoicePaySchedule_ID IN numeric, + p_DateAcct IN timestamp with time zone +) +RETURNS numeric +AS +$BODY$ +DECLARE + v_Currency_ID numeric(10); + v_Precision NUMERIC := 0; + v_Min NUMERIC := 0; + v_TotalOpenAmt numeric := 0; + v_PaidAmt numeric := 0; + v_Remaining numeric := 0; + v_MultiplierAP numeric := 0; + v_MultiplierCM numeric := 0; + v_Temp numeric := 0; + allocationline record; + invoiceschedule record; +BEGIN + -- Get Currency + BEGIN + SELECT MAX(C_Currency_ID), SUM(GrandTotal), MAX(MultiplierAP), MAX(Multiplier) + INTO v_Currency_ID, v_TotalOpenAmt, v_MultiplierAP, v_MultiplierCM + FROM C_Invoice_v -- corrected for CM / Split Payment + WHERE C_Invoice_ID = p_C_Invoice_ID + AND DateAcct <= p_DateAcct; + EXCEPTION -- Invoice in draft form + WHEN OTHERS THEN + --DBMS_OUTPUT.PUT_LINE('InvoiceOpen - ' || SQLERRM); + RETURN NULL; + END; +-- DBMS_OUTPUT.PUT_LINE('== C_Invoice_ID=' || p_C_Invoice_ID || ', Total=' || v_TotalOpenAmt || ', AP=' || v_MultiplierAP || ', CM=' || v_MultiplierCM); + + SELECT StdPrecision + INTO v_Precision + FROM C_Currency + WHERE C_Currency_ID = v_Currency_ID; + + SELECT 1/10^v_Precision INTO v_Min; + + -- Calculate Allocated Amount + FOR allocationline IN + SELECT a.AD_Client_ID, a.AD_Org_ID, + al.Amount, al.DiscountAmt, al.WriteOffAmt, + a.C_Currency_ID, a.DateTrx + FROM C_ALLOCATIONLINE al + INNER JOIN C_ALLOCATIONHDR a ON (al.C_AllocationHdr_ID=a.C_AllocationHdr_ID) + WHERE al.C_Invoice_ID = p_C_Invoice_ID + AND a.DateAcct <= p_DateAcct + AND a.IsActive='Y' + LOOP + v_Temp := allocationline.Amount + allocationline.DisCountAmt + allocationline.WriteOffAmt; + v_PaidAmt := v_PaidAmt + -- Allocation + + Currencyconvert(v_Temp * v_MultiplierAP, + allocationline.C_Currency_ID, v_Currency_ID, allocationline.DateTrx, NULL, allocationline.AD_Client_ID, allocationline.AD_Org_ID); + --DBMS_OUTPUT.PUT_LINE(' PaidAmt=' || v_PaidAmt || ', Allocation=' || v_Temp || ' * ' || v_MultiplierAP); + END LOOP; + + -- Do we have a Payment Schedule ? + IF (p_C_InvoicePaySchedule_ID > 0) THEN -- if not valid = lists invoice amount + v_Remaining := v_PaidAmt; + FOR invoiceschedule IN + SELECT C_InvoicePaySchedule_ID, DueAmt FROM C_INVOICEPAYSCHEDULE WHERE C_Invoice_ID = p_C_Invoice_ID AND IsValid='Y' + ORDER BY DueDate + LOOP + IF (invoiceschedule.C_InvoicePaySchedule_ID = p_C_InvoicePaySchedule_ID) THEN + v_TotalOpenAmt := (invoiceschedule.DueAmt*v_MultiplierCM) - v_Remaining; + IF (invoiceschedule.DueAmt - v_Remaining < 0) THEN + v_TotalOpenAmt := 0; + END IF; + -- DBMS_OUTPUT.PUT_LINE('Sched Total=' || v_TotalOpenAmt || ', Due=' || s.DueAmt || ',Remaining=' || v_Remaining || ',CM=' || v_MultiplierCM); + ELSE -- calculate amount, which can be allocated to next schedule + v_Remaining := v_Remaining - invoiceschedule.DueAmt; + IF (v_Remaining < 0) THEN + v_Remaining := 0; + END IF; + -- DBMS_OUTPUT.PUT_LINE('Remaining=' || v_Remaining); + END IF; + END LOOP; + ELSE + v_TotalOpenAmt := v_TotalOpenAmt - v_PaidAmt; + END IF; +-- DBMS_OUTPUT.PUT_LINE('== Total=' || v_TotalOpenAmt); + + -- Ignore Rounding + IF (v_TotalOpenAmt > -v_Min AND v_TotalOpenAmt < v_Min) THEN + v_TotalOpenAmt := 0; + END IF; + + -- Round to currency precision + v_TotalOpenAmt := ROUND(COALESCE(v_TotalOpenAmt,0), v_Precision); + + RETURN v_TotalOpenAmt; +END; +$BODY$ + LANGUAGE 'plpgsql' STABLE; + + +CREATE OR REPLACE FUNCTION InvoiceopenToDate +( + p_C_Invoice_ID IN numeric, + p_C_InvoicePaySchedule_ID IN numeric, + p_DateAcct IN date +) +RETURNS numeric +AS +$BODY$ +DECLARE + v_Currency_ID numeric(10); + v_Precision NUMERIC := 0; + v_Min NUMERIC := 0; + v_TotalOpenAmt numeric := 0; + v_PaidAmt numeric := 0; + v_Remaining numeric := 0; + v_MultiplierAP numeric := 0; + v_MultiplierCM numeric := 0; + v_Temp numeric := 0; + allocationline record; + invoiceschedule record; +BEGIN + -- Get Currency + BEGIN + SELECT MAX(C_Currency_ID), SUM(GrandTotal), MAX(MultiplierAP), MAX(Multiplier) + INTO v_Currency_ID, v_TotalOpenAmt, v_MultiplierAP, v_MultiplierCM + FROM C_Invoice_v -- corrected for CM / Split Payment + WHERE C_Invoice_ID = p_C_Invoice_ID + AND DateAcct <= p_DateAcct; + EXCEPTION -- Invoice in draft form + WHEN OTHERS THEN + --DBMS_OUTPUT.PUT_LINE('InvoiceOpen - ' || SQLERRM); + RETURN NULL; + END; +-- DBMS_OUTPUT.PUT_LINE('== C_Invoice_ID=' || p_C_Invoice_ID || ', Total=' || v_TotalOpenAmt || ', AP=' || v_MultiplierAP || ', CM=' || v_MultiplierCM); + + SELECT StdPrecision + INTO v_Precision + FROM C_Currency + WHERE C_Currency_ID = v_Currency_ID; + + SELECT 1/10^v_Precision INTO v_Min; + + -- Calculate Allocated Amount + FOR allocationline IN + SELECT a.AD_Client_ID, a.AD_Org_ID, + al.Amount, al.DiscountAmt, al.WriteOffAmt, + a.C_Currency_ID, a.DateTrx + FROM C_ALLOCATIONLINE al + INNER JOIN C_ALLOCATIONHDR a ON (al.C_AllocationHdr_ID=a.C_AllocationHdr_ID) + WHERE al.C_Invoice_ID = p_C_Invoice_ID + AND a.DateAcct <= p_DateAcct + AND a.IsActive='Y' + LOOP + v_Temp := allocationline.Amount + allocationline.DisCountAmt + allocationline.WriteOffAmt; + v_PaidAmt := v_PaidAmt + -- Allocation + + Currencyconvert(v_Temp * v_MultiplierAP, + allocationline.C_Currency_ID, v_Currency_ID, allocationline.DateTrx, NULL, allocationline.AD_Client_ID, allocationline.AD_Org_ID); + --DBMS_OUTPUT.PUT_LINE(' PaidAmt=' || v_PaidAmt || ', Allocation=' || v_Temp || ' * ' || v_MultiplierAP); + END LOOP; + + -- Do we have a Payment Schedule ? + IF (p_C_InvoicePaySchedule_ID > 0) THEN -- if not valid = lists invoice amount + v_Remaining := v_PaidAmt; + FOR invoiceschedule IN + SELECT C_InvoicePaySchedule_ID, DueAmt FROM C_INVOICEPAYSCHEDULE WHERE C_Invoice_ID = p_C_Invoice_ID AND IsValid='Y' + ORDER BY DueDate + LOOP + IF (invoiceschedule.C_InvoicePaySchedule_ID = p_C_InvoicePaySchedule_ID) THEN + v_TotalOpenAmt := (invoiceschedule.DueAmt*v_MultiplierCM) - v_Remaining; + IF (invoiceschedule.DueAmt - v_Remaining < 0) THEN + v_TotalOpenAmt := 0; + END IF; + -- DBMS_OUTPUT.PUT_LINE('Sched Total=' || v_TotalOpenAmt || ', Due=' || s.DueAmt || ',Remaining=' || v_Remaining || ',CM=' || v_MultiplierCM); + ELSE -- calculate amount, which can be allocated to next schedule + v_Remaining := v_Remaining - invoiceschedule.DueAmt; + IF (v_Remaining < 0) THEN + v_Remaining := 0; + END IF; + -- DBMS_OUTPUT.PUT_LINE('Remaining=' || v_Remaining); + END IF; + END LOOP; + ELSE + v_TotalOpenAmt := v_TotalOpenAmt - v_PaidAmt; + END IF; +-- DBMS_OUTPUT.PUT_LINE('== Total=' || v_TotalOpenAmt); + + -- Ignore Rounding + IF (v_TotalOpenAmt > -v_Min AND v_TotalOpenAmt < v_Min) THEN + v_TotalOpenAmt := 0; + END IF; + + -- Round to currency precision + v_TotalOpenAmt := ROUND(COALESCE(v_TotalOpenAmt,0), v_Precision); + + RETURN v_TotalOpenAmt; +END; +$BODY$ + LANGUAGE 'plpgsql' STABLE; + +CREATE OR REPLACE FUNCTION invoicePaid +( + p_C_Invoice_ID NUMERIC, + p_C_Currency_ID NUMERIC, + p_MultiplierAP NUMERIC -- DEFAULT 1 +) +RETURNS numeric AS $body$ +/************************************************************************* + * The contents of this file are subject to the Compiere License. You may + * obtain a copy of the License at http://www.compiere.org/license.html + * Software is on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either + * express or implied. See the License for details. Code: Compiere ERP+CRM + * Copyright (C) 1999-2001 Jorg Janke, ComPiere, Inc. All Rights Reserved. + * + * converted to postgreSQL by Karsten Thiemann (Schaeffer AG), + * kthiemann@adempiere.org + ************************************************************************* + *** + * Title: Calculate Paid/Allocated amount in Currency + * Description: + * Add up total amount paid for for C_Invoice_ID. + * Split Payments are ignored. + * all allocation amounts converted to invoice C_Currency_ID + * round it to the nearest cent + * and adjust for CreditMemos by using C_Invoice_v + * and for Payments with the multiplierAP (-1, 1) + * + * + * Test: + SELECT C_Invoice_ID, IsPaid, IsSOTrx, GrandTotal, + invoicePaid (C_Invoice_ID, C_Currency_ID, MultiplierAP) + FROM C_Invoice_v; + * + ************************************************************************/ +DECLARE + v_Precision NUMERIC := 0; + v_Min NUMERIC := 0; + v_MultiplierAP NUMERIC := 1; + v_PaymentAmt NUMERIC := 0; + ar RECORD; + +BEGIN + SELECT StdPrecision + INTO v_Precision + FROM C_Currency + WHERE C_Currency_ID = p_C_Currency_ID; + + SELECT 1/10^v_Precision INTO v_Min; + + -- Default + IF (p_MultiplierAP IS NOT NULL) THEN + v_MultiplierAP := p_MultiplierAP; + END IF; + -- Calculate Allocated Amount + FOR ar IN + SELECT a.AD_Client_ID, a.AD_Org_ID, + al.Amount, al.DiscountAmt, al.WriteOffAmt, + a.C_Currency_ID, a.DateTrx + FROM C_AllocationLine al + INNER JOIN C_AllocationHdr a ON (al.C_AllocationHdr_ID=a.C_AllocationHdr_ID) + WHERE al.C_Invoice_ID = p_C_Invoice_ID + AND a.IsActive='Y' + LOOP + v_PaymentAmt := v_PaymentAmt + + currencyConvert(ar.Amount + ar.DisCountAmt + ar.WriteOffAmt, + ar.C_Currency_ID, p_C_Currency_ID, ar.DateTrx, null, ar.AD_Client_ID, ar.AD_Org_ID); + END LOOP; + + -- Ignore Rounding + IF (v_PaymentAmt > -v_Min AND v_PaymentAmt < v_Min) THEN + v_PaymentAmt := 0; + END IF; + + -- Round to currency precision + v_PaymentAmt := ROUND(COALESCE(v_PaymentAmt,0), v_Precision); + + RETURN v_PaymentAmt * v_MultiplierAP; +END; + +$body$ LANGUAGE plpgsql STABLE; + +/* + *This file is part of Adempiere ERP Bazaar + *http://www.adempiere.org + *Copyright (C) 2006-2008 victor.perez@e-evolution.com, e-Evolution + *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 + * Title: Calculate Paid/Allocated amount in Currency + * Description: + * Add up total amount paid for for C_Invoice_ID. + * Split Payments are ignored. + * all allocation amounts converted to invoice C_Currency_ID + * round it to the nearest cent + * and adjust for CreditMemos by using C_Invoice_v + * and for Payments with the multiplierAP (-1, 1) + * + SELECT C_Invoice_ID, IsPaid, IsSOTrx, GrandTotal, + C_Invoice_Paid (C_Invoice_ID, C_Currency_ID, MultiplierAP, DateAcct) + FROM C_Invoice_v; + -- + UPDATE C_Invoice_v1 + SET IsPaid = CASE WHEN C_Invoice_Paid(C_Invoice_ID,C_Currency_ID,MultiplierAP,DateAcct)=GrandTotal THEN 'Y' ELSE 'N' END + WHERE C_Invoice_ID>1000000 + * + ************************************************************************/ + +CREATE OR REPLACE FUNCTION InvoicepaidToDate +( + p_C_Invoice_ID IN numeric, + p_C_Currency_ID IN numeric, + p_MultiplierAP IN numeric, -- DEFAULT 1 + p_DateAcct IN timestamp with time zone +) +RETURNS numeric +AS +$BODY$ +DECLARE + v_Precision NUMERIC := 0; + v_Min NUMERIC := 0; + v_MultiplierAP numeric := 1; + v_PaymentAmt numeric := 0; + allocation record; +BEGIN + SELECT StdPrecision + INTO v_Precision + FROM C_Currency + WHERE C_Currency_ID = p_C_Currency_ID; + + SELECT 1/10^v_Precision INTO v_Min; + + -- Default + IF (p_MultiplierAP IS NOT NULL) THEN + v_MultiplierAP := p_MultiplierAP; + END IF; + -- Calculate Allocated Amount + FOR allocation IN + SELECT al.AD_Client_ID, al.AD_Org_ID,al.Amount, al.DiscountAmt, al.WriteOffAmt,a.C_Currency_ID, a.DateTrx + FROM C_ALLOCATIONLINE al + INNER JOIN C_ALLOCATIONHDR a ON (al.C_AllocationHdr_ID=a.C_AllocationHdr_ID) + WHERE al.C_Invoice_ID = p_C_Invoice_ID AND a.IsActive='Y' AND a.DateAcct <= p_DateAcct + LOOP + v_PaymentAmt := v_PaymentAmt + + Currencyconvert(allocation.Amount + allocation.DisCountAmt + allocation.WriteOffAmt, + allocation.C_Currency_ID, p_C_Currency_ID, allocation.DateTrx, NULL, allocation.AD_Client_ID, allocation.AD_Org_ID); + END LOOP; + + -- Ignore Rounding + IF (v_PaymentAmt > -v_Min AND v_PaymentAmt < v_Min) THEN + v_PaymentAmt := 0; + END IF; + + -- Round to currency precision + v_PaymentAmt := ROUND(COALESCE(v_PaymentAmt,0), v_Precision); + + RETURN v_PaymentAmt * v_MultiplierAP; +END; +$BODY$ +LANGUAGE 'plpgsql' STABLE; + +create or replace FUNCTION paymenttermDiscount +( + Amount NUMERIC, + Currency_ID NUMERIC, + PaymentTerm_ID NUMERIC, + DocDate timestamp with time zone, + PayDate timestamp with time zone +) +RETURNS NUMERIC AS $body$ +/************************************************************************* + * The contents of this file are subject to the Compiere License. You may + * obtain a copy of the License at http://www.compiere.org/license.html + * Software is on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either + * express or implied. See the License for details. Code: Compiere ERP+CRM + * Copyright (C) 1999-2001 Jorg Janke, ComPiere, Inc. All Rights Reserved. + * + * converted to postgreSQL by Karsten Thiemann (Schaeffer AG), + * kthiemann@adempiere.org + ************************************************************************* + * Title: Calculate Discount + * Description: + * Calculate the allowable Discount Amount of the Payment Term + * + * Test: SELECT paymenttermDiscount(110, 103, 106, now(), now()) FROM TEST; => 2.20 + ************************************************************************/ + +DECLARE + v_Precision NUMERIC := 0; + v_Min NUMERIC := 0; + Discount NUMERIC := 0; + Discount1Date timestamp with time zone; + Discount2Date timestamp with time zone; + Add1Date NUMERIC := 0; + Add2Date NUMERIC := 0; + p RECORD; +BEGIN + SELECT StdPrecision + INTO v_Precision + FROM C_Currency + WHERE C_Currency_ID = Currency_ID; + + SELECT 1/10^v_Precision INTO v_Min; + + -- No Data - No Discount + IF (Amount IS NULL OR PaymentTerm_ID IS NULL OR DocDate IS NULL) THEN + RETURN 0; + END IF; + + FOR p IN + SELECT * + FROM C_PaymentTerm + WHERE C_PaymentTerm_ID = PaymentTerm_ID + LOOP -- for convineance only + Discount1Date := TRUNC(DocDate + p.DiscountDays + p.GraceDays); + Discount2Date := TRUNC(DocDate + p.DiscountDays2 + p.GraceDays); + + -- Next Business Day + IF (p.IsNextBusinessDay='Y') THEN + Discount1Date := nextBusinessDay(Discount1Date, p.AD_Client_ID); + Discount2Date := nextBusinessDay(Discount2Date, p.AD_Client_ID); + END IF; + + -- Discount 1 + IF (Discount1Date >= TRUNC(PayDate)) THEN + Discount := Amount * p.Discount / 100; + -- Discount 2 + ELSIF (Discount2Date >= TRUNC(PayDate)) THEN + Discount := Amount * p.Discount2 / 100; + END IF; + END LOOP; + + -- Ignore Rounding + IF (Discount > -v_Min AND Discount < v_Min) THEN + Discount := 0; + END IF; + + -- Round to currency precision + Discount := ROUND(COALESCE(Discount,0), v_Precision); + + RETURN Discount; +END; + +$body$ LANGUAGE plpgsql STABLE; + +CREATE OR REPLACE FUNCTION paymenttermduedate (in paymentterm_id numeric, in docdate timestamptz) RETURNS timestamptz AS +$BODY$ +/************************************************************************* + * The contents of this file are subject to the Compiere License. You may + * obtain a copy of the License at http://www.compiere.org/license.html + * Software is on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either + * express or implied. See the License for details. Code: Compiere ERP+CRM + * Copyright (C) 1999-2001 Jorg Janke, ComPiere, Inc. All Rights Reserved. + * + * converted to postgreSQL by Karsten Thiemann (Schaeffer AG), + * kthiemann@adempiere.org + ************************************************************************* + * Title: Get Due timestamp with time zone + * Description: + * Returns the due timestamp with time zone + * Test: + * select paymenttermDueDate(106, now()) from Test; => now()+30 days + ************************************************************************/ +DECLARE + Days NUMERIC := 0; + DueDate timestamp with time zone := TRUNC(DocDate); + -- + FirstDay timestamp with time zone; + NoDays NUMERIC; + p RECORD; +BEGIN + FOR p IN + SELECT * + FROM C_PaymentTerm + WHERE C_PaymentTerm_ID = PaymentTerm_ID + LOOP -- for convineance only + -- Due 15th of following month + IF (p.IsDueFixed = 'Y') THEN + FirstDay := TRUNC(DocDate, 'MM'); + NoDays := EXTRACT(day FROM TRUNC(DocDate) - FirstDay); + DueDate := FirstDay + (p.FixMonthDay-1); -- starting on 1st + DueDate := ADD_MONTHS(DueDate, p.FixMonthOffset); + IF (NoDays > p.FixMonthCutoff) THEN + DueDate := ADD_MONTHS(DueDate, 1); + END IF; + ELSE + DueDate := TRUNC(DocDate) + p.NetDays; + END IF; + END LOOP; + RETURN DueDate; +END; +$BODY$ +LANGUAGE 'plpgsql' STABLE +; + +create or replace FUNCTION paymenttermDueDays +( + PaymentTerm_ID IN NUMERIC, + DocDate IN timestamp with time zone, + PayDate IN timestamp with time zone +) +RETURNS INTEGER AS $body$ +/************************************************************************* + * The contents of this file are subject to the Compiere License. You may + * obtain a copy of the License at http://www.compiere.org/license.html + * Software is on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either + * express or implied. See the License for details. Code: Compiere ERP+CRM + * Copyright (C) 1999-2001 Jorg Janke, ComPiere, Inc. All Rights Reserved. + * + * converted to postgreSQL by Karsten Thiemann (Schaeffer AG), + * kthiemann@adempiere.org + ************************************************************************* + * Title: Get Due Days + * Description: + * Returns the days due (positive) or the days till due (negative) + * Grace days are not considered! + * If record is not found it assumes due immediately + * + * Test: SELECT paymenttermDueDays(103, now(), now()); + * + * Contributor(s): Carlos Ruiz - globalqss - match with SQLJ version + ************************************************************************/ +DECLARE + Days NUMERIC := 0; + DueDate timestamp with time zone := NULL; + calDueDate timestamp with time zone; + FixMonthOffset C_PaymentTerm.FixMonthOffset%TYPE; + MaxDayCut NUMERIC; + MaxDay NUMERIC; + v_PayDate timestamp with time zone; + p RECORD; + -- + FirstDay timestamp with time zone; + NoDays NUMERIC; +BEGIN + + IF PaymentTerm_ID = 0 OR DocDate IS NULL THEN + RETURN 0; + END IF; + + v_PayDate := PayDate; + IF v_PayDate IS NULL THEN + v_PayDate := TRUNC(now()); + END IF; + + FOR p IN + SELECT * + FROM C_PaymentTerm + WHERE C_PaymentTerm_ID = PaymentTerm_ID + LOOP -- for convineance only + + -- Due 15th of following month + IF (p.IsDueFixed = 'Y') THEN + FirstDay := TRUNC(DocDate, 'MM'); + NoDays := extract (day from (TRUNC(DocDate) - FirstDay)); + DueDate := FirstDay + (p.FixMonthDay-1); -- starting on 1st + DueDate := DueDate + (p.FixMonthOffset || ' month')::interval; + + IF (NoDays > p.FixMonthCutoff) THEN + DueDate := DueDate + '1 month'::interval; + END IF; + -- raise notice 'FirstDay: %, NoDays: %, DueDate: %', FirstDay, NoDays, DueDate; + + calDueDate := TRUNC(DocDate); + MaxDayCut := extract (day from (cast(date_trunc('month', calDueDate) + '1 month'::interval as date) - 1)); + -- raise notice 'last day(MaxDayCut): %' , MaxDayCut; + + IF p.FixMonthCutoff > MaxDayCut THEN + -- raise notice 'p.FixMonthCutoff > MaxDayCut'; + calDueDate := cast(date_trunc('month', TRUNC(calDueDate)) + '1 month'::interval as date) - 1; + -- raise notice 'last day(calDueDate): %' , calDueDate; + ELSE + -- set day fixmonthcutoff on duedate + calDueDate := TRUNC(calDueDate, 'MM') + (((p.FixMonthCutoff-1)|| ' days')::interval); + -- raise notice 'calDueDate: %' , calDueDate; + + END IF; + FixMonthOffset := p.FixMonthOffset; + IF DocDate > calDueDate THEN + FixMonthOffset := FixMonthOffset + 1; + raise notice 'FixMonthOffset: %' , FixMonthOffset; + END IF; + + calDueDate := calDueDate + (FixMonthOffset || ' month')::interval; + -- raise notice 'calDueDate: %' , calDueDate; + + MaxDay := extract (day from (cast(date_trunc('month', calDueDate) + '1 month'::interval as date) - 1)); + + + IF (p.FixMonthDay > MaxDay) -- 32 -> 28 + OR (p.FixMonthDay >= 30 AND MaxDay > p.FixMonthDay) THEN -- 30 -> 31 + calDueDate := TRUNC(calDueDate, 'MM') + (((MaxDay-1)|| ' days')::interval); + -- raise notice 'calDueDate: %' , calDueDate; + ELSE + calDueDate := TRUNC(calDueDate, 'MM') + (((p.FixMonthDay-1)|| ' days')::interval); + -- raise notice 'calDueDate: %' , calDueDate; + END IF; + DueDate := calDueDate; + + ELSE + DueDate := TRUNC(DocDate) + p.NetDays; + END IF; + END LOOP; + + IF DueDate IS NULL THEN + RETURN 0; + END IF; + + + Days := EXTRACT(day from (TRUNC(v_PayDate) - DueDate)); + RETURN Days; +END; + +$body$ LANGUAGE plpgsql STABLE; + + +create or replace FUNCTION paymentAllocated +( + p_C_Payment_ID IN NUMERIC, + p_C_Currency_ID IN NUMERIC +) +RETURNS NUMERIC AS $body$ +/************************************************************************* + * The contents of this file are subject to the Compiere License. You may + * obtain a copy of the License at http://www.compiere.org/license.html + * Software is on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either + * express or implied. See the License for details. Code: Compiere ERP+CRM + * Copyright (C) 1999-2001 Jorg Janke, ComPiere, Inc. All Rights Reserved. + * + * converted to postgreSQL by Karsten Thiemann (Schaeffer AG), + * kthiemann@adempiere.org + ************************************************************************* + * Title: Calculate Allocated Payment Amount in Payment Currency + * Description: + -- + SELECT paymentAllocated(C_Payment_ID,C_Currency_ID), PayAmt, IsAllocated + FROM C_Payment_v + WHERE C_Payment_ID<1000000; + -- + UPDATE C_Payment_v + SET IsAllocated=CASE WHEN paymentAllocated(C_Payment_ID, C_Currency_ID)=PayAmt THEN 'Y' ELSE 'N' END + WHERE C_Payment_ID>=1000000; + + ************************************************************************/ +DECLARE + v_Precision NUMERIC := 0; + v_Min NUMERIC := 0; + v_AllocatedAmt NUMERIC := 0; + v_PayAmt NUMERIC; + r RECORD; +BEGIN + SELECT StdPrecision + INTO v_Precision + FROM C_Currency + WHERE C_Currency_ID = p_C_Currency_ID; + + SELECT 1/10^v_Precision INTO v_Min; + + -- Charge - nothing available + SELECT + INTO v_PayAmt MAX(PayAmt) + FROM C_Payment + WHERE C_Payment_ID=p_C_Payment_ID AND C_Charge_ID > 0; + + IF (v_PayAmt IS NOT NULL) THEN + RETURN v_PayAmt; + END IF; + + -- Calculate Allocated Amount + FOR r IN + SELECT a.AD_Client_ID, a.AD_Org_ID, al.Amount, a.C_Currency_ID, a.DateTrx + FROM C_AllocationLine al + INNER JOIN C_AllocationHdr a ON (al.C_AllocationHdr_ID=a.C_AllocationHdr_ID) + WHERE al.C_Payment_ID = p_C_Payment_ID + AND a.IsActive='Y' + LOOP + v_AllocatedAmt := v_AllocatedAmt + + currencyConvert(r.Amount, r.C_Currency_ID, p_C_Currency_ID, r.DateTrx, null, r.AD_Client_ID, r.AD_Org_ID); + END LOOP; + + -- Ignore Rounding + IF (v_AllocatedAmt > -v_Min AND v_AllocatedAmt < v_Min) THEN + v_AllocatedAmt := 0; + END IF; + + -- Round to currency precision + v_AllocatedAmt := ROUND(COALESCE(v_AllocatedAmt,0), v_Precision); + + RETURN v_AllocatedAmt; +END; + +$body$ LANGUAGE plpgsql STABLE; + +create or replace FUNCTION paymentAvailable +( + p_C_Payment_ID IN NUMERIC +) +RETURNS NUMERIC AS $body$ +/************************************************************************* + * The contents of this file are subject to the Compiere License. You may + * obtain a copy of the License at http://www.compiere.org/license.html + * Software is on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either + * express or implied. See the License for details. Code: Compiere ERP+CRM + * Copyright (C) 1999-2001 Jorg Janke, ComPiere, Inc. All Rights Reserved. + * + * converted to postgreSQL by Karsten Thiemann (Schaeffer AG), + * kthiemann@adempiere.org + ************************************************************************* + * Title: Calculate Available Payment Amount in Payment Currency + * Description: + * similar to C_Invoice_Open + ************************************************************************/ +DECLARE + v_Currency_ID NUMERIC(10); + v_Precision NUMERIC := 0; + v_Min NUMERIC := 0; + v_AvailableAmt NUMERIC := 0; + v_IsReceipt C_Payment.IsReceipt%TYPE; + v_Amt NUMERIC := 0; + r RECORD; + +BEGIN + -- Charge - fully allocated + SELECT MAX(PayAmt) + INTO v_Amt + FROM C_Payment + WHERE C_Payment_ID=p_C_Payment_ID AND C_Charge_ID > 0; + IF (v_Amt IS NOT NULL) THEN + RETURN 0; + END IF; + + -- Get Currency + SELECT C_Currency_ID, PayAmt, IsReceipt + INTO v_Currency_ID, v_AvailableAmt, v_IsReceipt + FROM C_Payment_v -- corrected for AP/AR + WHERE C_Payment_ID = p_C_Payment_ID; +-- DBMS_OUTPUT.PUT_LINE('== C_Payment_ID=' || p_C_Payment_ID || ', PayAmt=' || v_AvailableAmt || ', Receipt=' || v_IsReceipt); + + SELECT StdPrecision + INTO v_Precision + FROM C_Currency + WHERE C_Currency_ID = v_Currency_ID; + + SELECT 1/10^v_Precision INTO v_Min; + + -- Calculate Allocated Amount + FOR r IN + SELECT a.AD_Client_ID, a.AD_Org_ID, al.Amount, a.C_Currency_ID, a.DateTrx + FROM C_AllocationLine al + INNER JOIN C_AllocationHdr a ON (al.C_AllocationHdr_ID=a.C_AllocationHdr_ID) + WHERE al.C_Payment_ID = p_C_Payment_ID + AND a.IsActive='Y' + LOOP + v_Amt := currencyConvert(r.Amount, r.C_Currency_ID, v_Currency_ID, r.DateTrx, null, r.AD_Client_ID, r.AD_Org_ID); + v_AvailableAmt := v_AvailableAmt - v_Amt; +-- DBMS_OUTPUT.PUT_LINE(' Allocation=' || a.Amount || ' - Available=' || v_AvailableAmt); + END LOOP; + + -- Ignore Rounding + IF (v_AvailableAmt > -v_Min AND v_AvailableAmt < v_Min) THEN + v_AvailableAmt := 0; + END IF; + + -- Round to currency precision + v_AvailableAmt := ROUND(COALESCE(v_AvailableAmt,0), v_Precision); + + RETURN v_AvailableAmt; +END; + +$body$ LANGUAGE plpgsql STABLE; + +set client_encoding='LATIN1'; + +CREATE OR REPLACE FUNCTION ProductAttribute +( + p_M_AttributeSetInstance_ID NUMERIC +) +RETURNS VARCHAR AS $body$ + +/************************************************************************* + * The contents of this file are subject to the Compiere License. You may + * obtain a copy of the License at http://www.compiere.org/license.html + * Software is on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either + * express or implied. See the License for details. Code: Compiere ERP+CRM + * Copyright (C) 1999-2001 Jorg Janke, ComPiere, Inc. All Rights Reserved. + * + * converted to postgreSQL by Karsten Thiemann (Schaeffer AG), + * kthiemann@adempiere.org + ************************************************************************* + * Title: Return Instance Attribute Info + * Description: + * + * Test: + SELECT ProductAttribute (M_AttributeSetInstance_ID) + FROM M_InOutLine WHERE M_AttributeSetInstance_ID > 0 + -- + SELECT p.Name + FROM C_InvoiceLine il LEFT OUTER JOIN M_Product p ON (il.M_Product_ID=p.M_Product_ID); + SELECT p.Name || ProductAttribute (il.M_AttributeSetInstance_ID) + FROM C_InvoiceLine il LEFT OUTER JOIN M_Product p ON (il.M_Product_ID=p.M_Product_ID); + + ************************************************************************/ + + +DECLARE + + v_Name VARCHAR(2000) := ''; + v_NameAdd VARCHAR(2000) := ''; + -- + v_Lot M_AttributeSetInstance.Lot%TYPE; + v_LotStart M_AttributeSet.LotCharSOverwrite%TYPE; + v_LotEnd M_AttributeSet.LotCharEOverwrite%TYPE; + v_SerNo M_AttributeSetInstance.SerNo%TYPE; + v_SerNoStart M_AttributeSet.SerNoCharSOverwrite%TYPE; + v_SerNoEnd M_AttributeSet.SerNoCharEOverwrite%TYPE; + v_GuaranteeDate M_AttributeSetInstance.GuaranteeDate%TYPE; + + r RECORD; + -- + +BEGIN + -- Get Product Attribute Set Instance + IF (p_M_AttributeSetInstance_ID > 0) THEN + SELECT asi.Lot, asi.SerNo, asi.GuaranteeDate, + COALESCE(a.SerNoCharSOverwrite, '#'::CHAR(1)), COALESCE(a.SerNoCharEOverwrite, ''::CHAR(1)), + COALESCE(a.LotCharSOverwrite, '«'::CHAR(1)), COALESCE(a.LotCharEOverwrite, '»'::CHAR(1)) + INTO v_Lot, v_SerNo, v_GuaranteeDate, + v_SerNoStart, v_SerNoEnd, v_LotStart, v_LotEnd + FROM M_AttributeSetInstance asi + INNER JOIN M_AttributeSet a ON (asi.M_AttributeSet_ID=a.M_AttributeSet_ID) + WHERE asi.M_AttributeSetInstance_ID=p_M_AttributeSetInstance_ID; + -- + IF (v_SerNo IS NOT NULL) THEN + v_NameAdd := v_NameAdd || v_SerNoStart || v_SerNo || v_SerNoEnd || ' '; + END IF; + IF (v_Lot IS NOT NULL) THEN + v_NameAdd := v_NameAdd || v_LotStart || v_Lot || v_LotEnd || ' '; + END IF; + IF (v_GuaranteeDate IS NOT NULL) THEN + v_NameAdd := v_NameAdd || v_GuaranteeDate || ' '; + END IF; + -- + + FOR r IN + SELECT ai.Value, a.Name + FROM M_AttributeInstance ai + INNER JOIN M_Attribute a ON (ai.M_Attribute_ID=a.M_Attribute_ID AND a.IsInstanceAttribute='Y') + WHERE ai.M_AttributeSetInstance_ID=p_M_AttributeSetInstance_ID + LOOP + v_NameAdd := v_NameAdd || r.Name || ':' || r.Value || ' '; + END LOOP; + -- + IF (LENGTH(v_NameAdd) > 0) THEN + v_Name := v_Name || ' (' || TRIM(v_NameAdd) || ')'; + ELSE + v_Name := NULL; + END IF; + END IF; + RETURN v_Name; +END; + +$body$ LANGUAGE plpgsql STABLE; + +/* +*This file is part of Adempiere ERP Bazaar +*http://www.adempiere.org +* +*Copyright (C) 2007 Low Heng Sin +*Copyright (C) 1999-2006 ComPiere, inc +* +*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 +*/ + +CREATE OR REPLACE FUNCTION addDays(datetime TIMESTAMP WITH TIME ZONE, days Numeric) +RETURNS DATE AS $$ +declare duration varchar; +BEGIN + if datetime is null or days is null then + return null; + end if; + duration = days || ' day'; + return cast(date_trunc('day',datetime) + cast(duration as interval) as date); +END; +$$ LANGUAGE plpgsql IMMUTABLE; + +CREATE OR REPLACE FUNCTION subtractdays (day TIMESTAMP WITH TIME ZONE, days NUMERIC) +RETURNS DATE AS $$ +BEGIN + RETURN addDays(day,(days * -1)); +END; +$$ LANGUAGE plpgsql IMMUTABLE; + +/* + *This file is part of Adempiere ERP Bazaar + *http://www.adempiere.org + * + *Copyright (C) 2006 Gavin Dunse + *Copyright (C) 1999-2006 ComPiere, inc + * + *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 + */ + +/** Get Character at Position */ +CREATE OR REPLACE FUNCTION charAt ( + IN VARCHAR, -- $1 the string + IN INTEGER -- $2 the position +) RETURNS VARCHAR AS +$$ + BEGIN + RETURN SUBSTR($1, $2, 1); + END; +$$ LANGUAGE plpgsql IMMUTABLE; + +/* +*This file is part of Adempiere ERP Bazaar +*http://www.adempiere.org +* +*Copyright (C) 2007 Low Heng Sin +*Copyright (C) 1999-2006 ComPiere, inc +* +*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 +*/ + +CREATE OR REPLACE FUNCTION daysBetween(p_date1 TIMESTAMP WITH TIME ZONE, p_date2 TIMESTAMP WITH TIME ZONE) +RETURNS INTEGER AS $$ +BEGIN + RETURN CAST(p_date1 AS DATE) - CAST(p_date2 as DATE); +END; +$$ LANGUAGE plpgsql IMMUTABLE; + +/* + *This file is part of Adempiere ERP Bazaar + *http://www.adempiere.org + *Copyright (C) 2006-2008 Antonio Cañaveral, e-Evolution + * + *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 + * Return the Document for Dcocument Type + */ +create or replace FUNCTION documentNo +( + p_PP_MRP_ID IN PP_MRP.PP_MRP_ID%TYPE +) +RETURNS PP_MRP.Value%TYPE +AS +$BODY$ +DECLARE + v_DocumentNo PP_MRP.Value%TYPE := ''; +BEGIN + -- If NO id return empty string + IF p_PP_MRP_ID <= 0 THEN + RETURN ''; + END IF; + SELECT --ordertype, m_forecast_id, c_order_id, dd_order_id, pp_order_id, m_requisition_id, + CASE + WHEN trim(mrp.ordertype) = 'FTC' THEN (SELECT f.Name FROM M_Forecast f WHERE f.M_Forecast_ID=mrp.M_Forecast_ID) + WHEN trim(mrp.ordertype) = 'POO' THEN (SELECT co.DocumentNo FROM C_Order co WHERE co.C_Order_ID=mrp.C_Order_ID) + WHEN trim(mrp.ordertype) = 'DOO' THEN (SELECT dd.DocumentNo FROM DD_Order dd WHERE dd.DD_Order_ID=mrp.DD_Order_ID) + WHEN trim(mrp.ordertype) = 'SOO' THEN (SELECT co.DocumentNo FROM C_Order co WHERE co.C_Order_ID=mrp.C_Order_ID) + WHEN trim(mrp.ordertype) = 'MOP' THEN (SELECT po.DocumentNo FROM PP_Order po WHERE po.PP_Order_ID=mrp.PP_Order_ID) + WHEN trim(mrp.ordertype) = 'POR' THEN (SELECT r.DocumentNo FROM M_Requisition r WHERE r.M_Requisition_ID=mrp.M_Requisition_ID) + + END INTO v_DocumentNo + FROM pp_mrp mrp + WHERE mrp.pp_mrp_id = p_PP_MRP_ID; + RETURN v_DocumentNo; +END; +$BODY$ + LANGUAGE 'plpgsql' STABLE; + +/* +*This file is part of Adempiere ERP Bazaar +*http://www.adempiere.org +* +*Copyright (C) 2006 Gavin Dunse +*Copyright (C) 1999-2006 ComPiere, inc +* +*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 +*/ + +/** Get Character at Position */ +SET search_path = adempiere, pg_catalog; + +CREATE OR REPLACE FUNCTION firstOf ( +IN TIMESTAMP WITH TIME ZONE, -- $1 date +IN VARCHAR -- $2 part of date +) RETURNS DATE AS +$$ +DECLARE +datepart VARCHAR; +datetime TIMESTAMP WITH TIME ZONE; +offsetdays INTEGER; +BEGIN + datepart = $2; + offsetdays = 0; + IF $2 IN ('') THEN + datepart = 'millennium'; + ELSEIF $2 IN ('') THEN + datepart = 'century'; + ELSEIF $2 IN ('') THEN + datepart = 'decade'; + ELSEIF $2 IN ('IYYY','IY','I') THEN + datepart = 'year'; + ELSEIF $2 IN ('SYYYY','YYYY','YEAR','SYEAR','YYY','YY','Y') THEN + datepart = 'year'; + ELSEIF $2 IN ('Q') THEN + datepart = 'quarter'; + ELSEIF $2 IN ('MONTH','MON','MM','RM') THEN + datepart = 'month'; + ELSEIF $2 IN ('IW') THEN + datepart = 'week'; + ELSEIF $2 IN ('W') THEN + datepart = 'week'; + ELSEIF $2 IN ('DDD','DD','J') THEN + datepart = 'day'; + ELSEIF $2 IN ('DAY','DY','D') THEN + datepart = 'week'; + -- move to sunday to make it compatible with oracle and SQLJ + offsetdays = -1; + ELSEIF $2 IN ('HH','HH12','HH24') THEN + datepart = 'hour'; + ELSEIF $2 IN ('MI') THEN + datepart = 'minute'; + ELSEIF $2 IN ('') THEN + datepart = 'second'; + ELSEIF $2 IN ('') THEN + datepart = 'milliseconds'; + ELSEIF $2 IN ('') THEN + datepart = 'microseconds'; + END IF; + datetime = date_trunc(datepart, $1); +RETURN cast(datetime as date) + offsetdays; +END; +$$ LANGUAGE plpgsql IMMUTABLE; + +CREATE OR REPLACE FUNCTION get1099bucket ( + p_cbpartner_id IN numeric, + p_cut_date IN timestamp with time zone, + p_bucket IN numeric +) + RETURNS numeric +AS +$BODY$ +DECLARE + tmpvar numeric; +/****************************************************************************** + NAME: get1099bucket + PURPOSE: + + REVISIONS: + Ver Date Author Description + --------- ---------- --------------- ------------------------------------ + 1.0 04/01/2008 Carlos Ruiz 1. Created this function. + +******************************************************************************/ +BEGIN + SELECT SUM ( (COALESCE (linenetamt, 0) + COALESCE (taxamt, 0)) + * (CASE WHEN docbasetype = 'API' THEN 1 + WHEN docbasetype = 'APC' THEN -1 + ELSE 0 + END) + ) -- +API->AP Invoice / -APC->AP Credit Memo + INTO tmpvar + FROM C_INVOICE i, C_INVOICELINE il, C_1099BOX b, C_DOCTYPE dt + WHERE i.c_invoice_id = il.c_invoice_id + AND i.issotrx = 'N' + AND il.c_1099box_id = b.c_1099box_id + AND i.dateacct BETWEEN TRUNC (p_cut_date, 'YEAR') AND p_cut_date + AND c_bpartner_id = p_cbpartner_id + AND b.bucket = p_bucket + AND i.c_doctype_id = dt.c_doctype_id + AND i.docstatus IN ('CO', 'CL'); + + RETURN tmpvar; +END; +$BODY$ + LANGUAGE plpgsql STABLE +; + +/* + *This file is part of Adempiere ERP Bazaar + *http://www.adempiere.org + *Copyright (C) 2006-2008 victor.perez@e-evolution.com, e-Evolution + *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 + * + * Author: Carlos Ruiz (globalqss) + */ +CREATE OR REPLACE FUNCTION get_Sysconfig +( + sysconfig_name ad_sysconfig.name%TYPE, + defaultvalue ad_sysconfig.value%TYPE, + client_id ad_sysconfig.ad_client_id%TYPE, + org_id ad_sysconfig.ad_org_id%TYPE +) +RETURNS ad_sysconfig.value%TYPE +AS +$BODY$ +DECLARE + v_value ad_sysconfig.value%TYPE; +BEGIN + BEGIN + SELECT Value + INTO STRICT v_value + FROM AD_SysConfig WHERE Name=sysconfig_name AND AD_Client_ID IN (0, client_id) AND AD_Org_ID IN (0, org_id) AND IsActive='Y' + ORDER BY AD_Client_ID DESC, AD_Org_ID DESC + LIMIT 1; + EXCEPTION + WHEN NO_DATA_FOUND THEN + v_value := defaultvalue; + END; + RETURN v_value; +END; +$BODY$ + LANGUAGE 'plpgsql' STABLE; + +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 STABLE; + +CREATE OR REPLACE FUNCTION prodqtyordered(p_product_id numeric, p_warehouse_id numeric) + RETURNS numeric AS +$BODY$ +DECLARE + v_Warehouse_ID numeric; + v_Quantity numeric := 99999; -- unlimited + v_IsBOM CHAR(1); + v_IsStocked CHAR(1); + v_ProductType CHAR(1); + v_ProductQty numeric; + v_StdPrecision int; +BEGIN + -- Check Parameters + v_Warehouse_ID := p_Warehouse_ID; + IF (v_Warehouse_ID IS NULL) THEN + RETURN 0; + END IF; +-- DBMS_OUTPUT.PUT_LINE('Warehouse=' || v_Warehouse_ID); + + -- Check, if product exists and if it is stocked + BEGIN + SELECT IsBOM, ProductType, IsStocked + INTO v_IsBOM, v_ProductType, v_IsStocked + FROM M_PRODUCT + WHERE M_Product_ID=p_Product_ID; + -- + EXCEPTION -- not found + WHEN OTHERS THEN + RETURN 0; + END; + + -- No reservation for non-stocked + IF (v_IsStocked='Y') THEN + -- Get ProductQty + SELECT COALESCE(SUM(MovementQty), 0) + INTO v_ProductQty + FROM M_ProductionLine p + WHERE M_Product_ID=p_Product_ID AND MovementQty > 0 AND p.Processed = 'N' + AND EXISTS (SELECT * FROM M_LOCATOR l WHERE p.M_Locator_ID=l.M_Locator_ID + AND l.M_Warehouse_ID=v_Warehouse_ID); + -- + RETURN v_ProductQty; + END IF; + + -- Unlimited (e.g. only services) + IF (v_Quantity = 99999) THEN + RETURN 0; + END IF; + + IF (v_Quantity > 0) THEN + -- Get Rounding Precision for Product + SELECT COALESCE(MAX(u.StdPrecision), 0) + INTO v_StdPrecision + FROM C_UOM u, M_PRODUCT p + WHERE u.C_UOM_ID=p.C_UOM_ID AND p.M_Product_ID=p_Product_ID; + -- + RETURN ROUND (v_Quantity, v_StdPrecision); + END IF; + RETURN 0; +END; +$BODY$ + LANGUAGE plpgsql STABLE +; + +CREATE OR REPLACE FUNCTION prodqtyreserved(p_product_id numeric, p_warehouse_id numeric) + RETURNS numeric AS +$BODY$ +DECLARE + v_Warehouse_ID numeric; + v_Quantity numeric := 99999; -- unlimited + v_IsBOM CHAR(1); + v_IsStocked CHAR(1); + v_ProductType CHAR(1); + v_ProductQty numeric; + v_StdPrecision int; +BEGIN + -- Check Parameters + v_Warehouse_ID := p_Warehouse_ID; + IF (v_Warehouse_ID IS NULL) THEN + RETURN 0; + END IF; +-- DBMS_OUTPUT.PUT_LINE('Warehouse=' || v_Warehouse_ID); + + -- Check, if product exists and if it is stocked +BEGIN + SELECT IsBOM, ProductType, IsStocked + INTO v_IsBOM, v_ProductType, v_IsStocked + FROM M_PRODUCT + WHERE M_Product_ID=p_Product_ID; + -- + EXCEPTION -- not found + WHEN OTHERS THEN + RETURN 0; + END; + + -- No reservation for non-stocked + IF (v_IsStocked='Y') THEN + -- Get ProductQty + SELECT -1*COALESCE(SUM(MovementQty), 0) + INTO v_ProductQty + FROM M_ProductionLine p + WHERE M_Product_ID=p_Product_ID AND MovementQty < 0 AND p.Processed = 'N' + AND EXISTS (SELECT * FROM M_LOCATOR l WHERE p.M_Locator_ID=l.M_Locator_ID + AND l.M_Warehouse_ID=v_Warehouse_ID); + -- + RETURN v_ProductQty; + END IF; + + -- Unlimited (e.g. only services) + IF (v_Quantity = 99999) THEN + RETURN 0; + END IF; + + IF (v_Quantity > 0) THEN + -- Get Rounding Precision for Product + SELECT COALESCE(MAX(u.StdPrecision), 0) + INTO v_StdPrecision + FROM C_UOM u, M_PRODUCT p + WHERE u.C_UOM_ID=p.C_UOM_ID AND p.M_Product_ID=p_Product_ID; + -- + RETURN ROUND (v_Quantity, v_StdPrecision); + END IF; + RETURN 0; +END; +$BODY$ + LANGUAGE plpgsql STABLE +; + +CREATE OR REPLACE FUNCTION round ( + IN NUMERIC, -- $1 numeric + IN NUMERIC -- $2 numeric +) RETURNS NUMERIC AS +$$ + BEGIN + RETURN ROUND($1, cast($2 as integer)); + END; +$$ LANGUAGE plpgsql IMMUTABLE; + +/* +*This file is part of Adempiere ERP Bazaar +*http://www.adempiere.org +* +*Copyright (C) 2007 Low Heng Sin +*Copyright (C) 1999-2006 ComPiere, inc +* +*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 +*/ +CREATE OR REPLACE FUNCTION trunc(datetime TIMESTAMP WITH TIME ZONE) +RETURNS TIMESTAMP WITH TIME ZONE AS $$ +BEGIN + RETURN CAST(datetime AS DATE); +END; +$$ LANGUAGE plpgsql IMMUTABLE; + +CREATE OR REPLACE FUNCTION trunc(datetime TIMESTAMP WITH TIME ZONE, format varchar) +RETURNS DATE AS $$ +BEGIN + IF format = 'Q' THEN + RETURN CAST(DATE_Trunc('quarter',datetime) as DATE); + ELSIF format = 'Y' or format = 'YEAR' THEN + RETURN CAST(DATE_Trunc('year',datetime) as DATE); + ELSIF format = 'MM' or format = 'MONTH' THEN + RETURN CAST(DATE_Trunc('month',datetime) as DATE); + ELSIF format = 'DD' THEN + RETURN CAST(DATE_Trunc('day',datetime) as DATE); + ELSIF format = 'DY' THEN + RETURN CAST(DATE_Trunc('day',datetime) as DATE); + ELSE + RETURN CAST(datetime AS DATE); + END IF; +END; +$$ LANGUAGE plpgsql IMMUTABLE; + +CREATE OR REPLACE FUNCTION trunc(i INTERVAL) +RETURNS INTEGER AS $$ +BEGIN + RETURN EXTRACT(DAY FROM i); +END; +$$ LANGUAGE plpgsql IMMUTABLE; + + +SELECT register_migration_script('201405301149_IDEMPIERE-1953.sql') FROM dual +; diff --git a/org.adempiere.base.process/src/org/compiere/process/ProductionCreate.java b/org.adempiere.base.process/src/org/compiere/process/ProductionCreate.java index 353e739b8e..d6bcac1c9f 100644 --- a/org.adempiere.base.process/src/org/compiere/process/ProductionCreate.java +++ b/org.adempiere.base.process/src/org/compiere/process/ProductionCreate.java @@ -83,7 +83,7 @@ public class ProductionCreate extends SvrProcess { { costPercentageDiff = Env.ZERO; String msg = "Could not retrieve costs"; - if (MSysConfig.getBooleanValue("MFG_ValidateCostsOnCreate", false, getAD_Client_ID())) { + if (MSysConfig.getBooleanValue(MSysConfig.MFG_ValidateCostsOnCreate, false, getAD_Client_ID())) { throw new AdempiereUserError(msg); } else { log.warning(msg); @@ -141,7 +141,7 @@ public class ProductionCreate extends SvrProcess { if (!costsOK(M_Product_ID)) { String msg = "Excessive difference in standard costs"; - if (MSysConfig.getBooleanValue("MFG_ValidateCostsDifferenceOnCreate", false, getAD_Client_ID())) { + if (MSysConfig.getBooleanValue(MSysConfig.MFG_ValidateCostsDifferenceOnCreate, false, getAD_Client_ID())) { throw new AdempiereUserError("Excessive difference in standard costs"); } else { log.warning(msg); diff --git a/org.adempiere.base/src/org/adempiere/model/MInfoProcess.java b/org.adempiere.base/src/org/adempiere/model/MInfoProcess.java new file mode 100644 index 0000000000..101eb3f568 --- /dev/null +++ b/org.adempiere.base/src/org/adempiere/model/MInfoProcess.java @@ -0,0 +1,55 @@ +/****************************************************************************** + * Product: iDempiere ERP & CRM Smart Business Solution * + * This program is free software; you can redistribute it and/or modify it * + * under the terms version 2 of the GNU General Public License as published * + * by the Free Software Foundation. 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., * + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * + *****************************************************************************/ + +package org.adempiere.model; + +import java.sql.ResultSet; +import java.util.Properties; + +import org.compiere.model.X_AD_InfoProcess; + +/** + * Contain info of process in info window + * include process_id, image name, name + * @author hieplq + * + */ +public class MInfoProcess extends X_AD_InfoProcess { + /** + * + */ + private static final long serialVersionUID = 4978433930748011554L; + + /** + * {@inheritDoc} + * @param ctx + * @param AD_InfoProcess_ID + * @param trxName + */ + public MInfoProcess(Properties ctx, int AD_InfoProcess_ID, String trxName) { + super(ctx, AD_InfoProcess_ID, trxName); + + } + + /** + * {@inheritDoc} + * @param ctx + * @param rs + * @param trxName + */ + public MInfoProcess(Properties ctx, ResultSet rs, String trxName) { + super(ctx, rs, trxName); + + } + +} diff --git a/org.adempiere.base/src/org/compiere/model/I_AD_InfoProcess.java b/org.adempiere.base/src/org/compiere/model/I_AD_InfoProcess.java new file mode 100644 index 0000000000..8b4aeb384d --- /dev/null +++ b/org.adempiere.base/src/org/compiere/model/I_AD_InfoProcess.java @@ -0,0 +1,198 @@ +/****************************************************************************** + * Product: iDempiere ERP & CRM Smart Business Solution * + * Copyright (C) 1999-2012 ComPiere, Inc. All Rights Reserved. * + * This program is free software, you can redistribute it and/or modify it * + * under the terms version 2 of the GNU General Public License as published * + * by the Free Software Foundation. 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., * + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * + * For the text or an alternative of this public license, you may reach us * + * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * + * or via info@compiere.org or http://www.compiere.org/license.html * + *****************************************************************************/ +package org.compiere.model; + +import java.math.BigDecimal; +import java.sql.Timestamp; +import org.compiere.util.KeyNamePair; + +/** Generated Interface for AD_InfoProcess + * @author iDempiere (generated) + * @version Release 2.0 + */ +public interface I_AD_InfoProcess +{ + + /** TableName=AD_InfoProcess */ + public static final String Table_Name = "AD_InfoProcess"; + + /** AD_Table_ID=200129 */ + public static final int Table_ID = 200129; + + KeyNamePair Model = new KeyNamePair(Table_ID, Table_Name); + + /** AccessLevel = 4 - System + */ + BigDecimal accessLevel = BigDecimal.valueOf(4); + + /** Load Meta Data */ + + /** Column name AD_Client_ID */ + public static final String COLUMNNAME_AD_Client_ID = "AD_Client_ID"; + + /** Get Client. + * Client/Tenant for this installation. + */ + public int getAD_Client_ID(); + + /** Column name AD_InfoProcess_ID */ + public static final String COLUMNNAME_AD_InfoProcess_ID = "AD_InfoProcess_ID"; + + /** Set Info Process */ + public void setAD_InfoProcess_ID (int AD_InfoProcess_ID); + + /** Get Info Process */ + public int getAD_InfoProcess_ID(); + + /** Column name AD_InfoProcess_UU */ + public static final String COLUMNNAME_AD_InfoProcess_UU = "AD_InfoProcess_UU"; + + /** Set AD_InfoProcess_UU */ + public void setAD_InfoProcess_UU (String AD_InfoProcess_UU); + + /** Get AD_InfoProcess_UU */ + public String getAD_InfoProcess_UU(); + + /** Column name AD_InfoWindow_ID */ + public static final String COLUMNNAME_AD_InfoWindow_ID = "AD_InfoWindow_ID"; + + /** Set Info Window. + * Info and search/select Window + */ + public void setAD_InfoWindow_ID (int AD_InfoWindow_ID); + + /** Get Info Window. + * Info and search/select Window + */ + public int getAD_InfoWindow_ID(); + + public org.compiere.model.I_AD_InfoWindow getAD_InfoWindow() throws RuntimeException; + + /** Column name AD_Org_ID */ + public static final String COLUMNNAME_AD_Org_ID = "AD_Org_ID"; + + /** Set Organization. + * Organizational entity within client + */ + public void setAD_Org_ID (int AD_Org_ID); + + /** Get Organization. + * Organizational entity within client + */ + public int getAD_Org_ID(); + + /** Column name AD_Process_ID */ + public static final String COLUMNNAME_AD_Process_ID = "AD_Process_ID"; + + /** Set Process. + * Process or Report + */ + public void setAD_Process_ID (int AD_Process_ID); + + /** Get Process. + * Process or Report + */ + public int getAD_Process_ID(); + + public org.compiere.model.I_AD_Process getAD_Process() throws RuntimeException; + + /** Column name Created */ + public static final String COLUMNNAME_Created = "Created"; + + /** Get Created. + * Date this record was created + */ + public Timestamp getCreated(); + + /** Column name CreatedBy */ + public static final String COLUMNNAME_CreatedBy = "CreatedBy"; + + /** Get Created By. + * User who created this records + */ + public int getCreatedBy(); + + /** Column name ImageURL */ + public static final String COLUMNNAME_ImageURL = "ImageURL"; + + /** Set Image URL. + * URL of image + */ + public void setImageURL (String ImageURL); + + /** Get Image URL. + * URL of image + */ + public String getImageURL(); + + /** Column name IsActive */ + public static final String COLUMNNAME_IsActive = "IsActive"; + + /** Set Active. + * The record is active in the system + */ + public void setIsActive (boolean IsActive); + + /** Get Active. + * The record is active in the system + */ + public boolean isActive(); + + /** Column name LayoutType */ + public static final String COLUMNNAME_LayoutType = "LayoutType"; + + /** Set LayoutType. + * Layout type of info process + */ + public void setLayoutType (String LayoutType); + + /** Get LayoutType. + * Layout type of info process + */ + public String getLayoutType(); + + /** Column name SeqNo */ + public static final String COLUMNNAME_SeqNo = "SeqNo"; + + /** Set Sequence. + * Method of ordering records; + lowest number comes first + */ + public void setSeqNo (int SeqNo); + + /** Get Sequence. + * Method of ordering records; + lowest number comes first + */ + public int getSeqNo(); + + /** Column name Updated */ + public static final String COLUMNNAME_Updated = "Updated"; + + /** Get Updated. + * Date this record was updated + */ + public Timestamp getUpdated(); + + /** Column name UpdatedBy */ + public static final String COLUMNNAME_UpdatedBy = "UpdatedBy"; + + /** Get Updated By. + * User who updated this records + */ + public int getUpdatedBy(); +} diff --git a/org.adempiere.base/src/org/compiere/model/I_AD_InfoWindow.java b/org.adempiere.base/src/org/compiere/model/I_AD_InfoWindow.java index 164a063eec..d0b848e1b6 100644 --- a/org.adempiere.base/src/org/compiere/model/I_AD_InfoWindow.java +++ b/org.adempiere.base/src/org/compiere/model/I_AD_InfoWindow.java @@ -95,21 +95,6 @@ public interface I_AD_InfoWindow */ public int getAD_Org_ID(); - /** Column name AD_Process_ID */ - public static final String COLUMNNAME_AD_Process_ID = "AD_Process_ID"; - - /** Set Process. - * Process or Report - */ - public void setAD_Process_ID (int AD_Process_ID); - - /** Get Process. - * Process or Report - */ - public int getAD_Process_ID(); - - public org.compiere.model.I_AD_Process getAD_Process() throws RuntimeException; - /** Column name AD_Table_ID */ public static final String COLUMNNAME_AD_Table_ID = "AD_Table_ID"; diff --git a/org.adempiere.base/src/org/compiere/model/MBPartnerLocation.java b/org.adempiere.base/src/org/compiere/model/MBPartnerLocation.java index 49ad562d07..86d884d207 100644 --- a/org.adempiere.base/src/org/compiere/model/MBPartnerLocation.java +++ b/org.adempiere.base/src/org/compiere/model/MBPartnerLocation.java @@ -35,7 +35,7 @@ public class MBPartnerLocation extends X_C_BPartner_Location { /** * */ - private static final long serialVersionUID = 1062151267747257338L; + private static final long serialVersionUID = -8412652367051443276L; /** * Get Locations for BPartner @@ -227,7 +227,7 @@ public class MBPartnerLocation extends X_C_BPartner_Location { public String getBPLocName(MLocation address) { m_uniqueName = getName(); - m_unique = MSysConfig.getIntValue("START_VALUE_BPLOCATION_NAME", 0, + m_unique = MSysConfig.getIntValue(MSysConfig.START_VALUE_BPLOCATION_NAME, 0, getAD_Client_ID(), getAD_Org_ID()); if (m_unique < 0 || m_unique > 4) m_unique = 0; diff --git a/org.adempiere.base/src/org/compiere/model/MClient.java b/org.adempiere.base/src/org/compiere/model/MClient.java index aa2067c268..51a06cd44d 100644 --- a/org.adempiere.base/src/org/compiere/model/MClient.java +++ b/org.adempiere.base/src/org/compiere/model/MClient.java @@ -17,9 +17,6 @@ *****************************************************************************/ package org.compiere.model; -import static org.compiere.model.MSysConfig.CLIENT_ACCOUNTING; -import static org.compiere.model.MSysConfig.MAIL_SEND_CREDENTIALS; - import java.io.File; import java.sql.PreparedStatement; import java.sql.ResultSet; @@ -59,7 +56,7 @@ public class MClient extends X_AD_Client /** * */ - private static final long serialVersionUID = 3043792947325698506L; + private static final long serialVersionUID = -4479164806149932775L; /** * Get client @@ -922,21 +919,21 @@ public class MClient extends X_AD_Client private static final String CLIENT_ACCOUNTING_IMMEDIATE = "I"; public static boolean isClientAccounting() { - String ca = MSysConfig.getValue(CLIENT_ACCOUNTING, + String ca = MSysConfig.getValue(MSysConfig.CLIENT_ACCOUNTING, CLIENT_ACCOUNTING_QUEUE, // default Env.getAD_Client_ID(Env.getCtx())); return (ca.equalsIgnoreCase(CLIENT_ACCOUNTING_IMMEDIATE) || ca.equalsIgnoreCase(CLIENT_ACCOUNTING_QUEUE)); } public static boolean isClientAccountingQueue() { - String ca = MSysConfig.getValue(CLIENT_ACCOUNTING, + String ca = MSysConfig.getValue(MSysConfig.CLIENT_ACCOUNTING, CLIENT_ACCOUNTING_QUEUE, // default Env.getAD_Client_ID(Env.getCtx())); return ca.equalsIgnoreCase(CLIENT_ACCOUNTING_QUEUE); } public static boolean isClientAccountingImmediate() { - String ca = MSysConfig.getValue(CLIENT_ACCOUNTING, + String ca = MSysConfig.getValue(MSysConfig.CLIENT_ACCOUNTING, CLIENT_ACCOUNTING_QUEUE, // default Env.getAD_Client_ID(Env.getCtx())); return ca.equalsIgnoreCase(CLIENT_ACCOUNTING_IMMEDIATE); @@ -1086,14 +1083,14 @@ public class MClient extends X_AD_Client private static final String MAIL_SEND_CREDENTIALS_SYSTEM = "S"; public static boolean isSendCredentialsClient() { - String msc = MSysConfig.getValue(MAIL_SEND_CREDENTIALS, + String msc = MSysConfig.getValue(MSysConfig.MAIL_SEND_CREDENTIALS, MAIL_SEND_CREDENTIALS_USER, // default Env.getAD_Client_ID(Env.getCtx())); return (MAIL_SEND_CREDENTIALS_CLIENT.equalsIgnoreCase(msc)); } public static boolean isSendCredentialsSystem() { - String msc = MSysConfig.getValue(MAIL_SEND_CREDENTIALS, + String msc = MSysConfig.getValue(MSysConfig.MAIL_SEND_CREDENTIALS, MAIL_SEND_CREDENTIALS_USER, // default Env.getAD_Client_ID(Env.getCtx())); return (MAIL_SEND_CREDENTIALS_SYSTEM.equalsIgnoreCase(msc)); diff --git a/org.adempiere.base/src/org/compiere/model/MInfoWindow.java b/org.adempiere.base/src/org/compiere/model/MInfoWindow.java index 3acec43ed4..ee9a3b7d67 100644 --- a/org.adempiere.base/src/org/compiere/model/MInfoWindow.java +++ b/org.adempiere.base/src/org/compiere/model/MInfoWindow.java @@ -19,10 +19,12 @@ package org.compiere.model; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; +import java.util.Iterator; import java.util.List; import java.util.Properties; import java.util.logging.Level; +import org.adempiere.model.MInfoProcess; import org.adempiere.model.MInfoRelated; import org.compiere.model.AccessSqlParser.TableInfo; import org.compiere.util.DB; @@ -40,7 +42,7 @@ public class MInfoWindow extends X_AD_InfoWindow /** * */ - private static final long serialVersionUID = -4228782755777501270L; + private static final long serialVersionUID = -3099366897275960300L; /** * Standard Constructor @@ -110,6 +112,12 @@ public class MInfoWindow extends X_AD_InfoWindow */ private MInfoRelated[] m_infoRelated; + /** + * IDEMPIERE-1334 + * cache list process button info + */ + private MInfoProcess[] m_infoProcess; + public MInfoRelated[] getInfoRelated(boolean requery) { if ((this.m_infoRelated != null) && (!requery)) { set_TrxName(this.m_infoRelated, get_TrxName()); @@ -127,6 +135,49 @@ public class MInfoWindow extends X_AD_InfoWindow return m_infoRelated; } + /** + * IDEMPIERE-1334 + * Get list {@link MInfoProcess} of this infoWindow + * @param requery true get from db, false try get from cache + * @return empty array when not exists Info Process + */ + public MInfoProcess [] getInfoProcess(boolean requery) { + // try from cache + if ((this.m_infoProcess != null) && (!requery)) { + set_TrxName(this.m_infoProcess, get_TrxName()); + return this.m_infoProcess; + } + + // get list info process from db, order by seqNo + List list = new Query(getCtx(), MInfoProcess.Table_Name, "AD_InfoWindow_ID=?", get_TrxName()) + .setParameters(getAD_InfoWindow_ID()) + .setOnlyActiveRecords(true) + .setOrderBy("SeqNo") + .list(); + + checkProcessRight(list); + m_infoProcess = list.toArray(new MInfoProcess[list.size()]); + + return m_infoProcess; + } + + + /** + * if user haven't right to run a process, set infoProcess to null + * @param lsInfoProcess + */ + protected void checkProcessRight (List lsInfoProcess) { + Iterator iterator = lsInfoProcess.iterator(); + while (iterator.hasNext()){ + MInfoProcess testInfoProcess = iterator.next(); + // need more review + if (MRole.getDefault().getProcessAccess(testInfoProcess.getAD_Process_ID()) == null){ + iterator.remove(); + } + } + + } + public MInfoColumn[] getInfoColumns(TableInfo[] tableInfos) { Query query = new Query(getCtx(), MTable.get(getCtx(), I_AD_InfoColumn.Table_ID), I_AD_InfoColumn.COLUMNNAME_AD_InfoWindow_ID+"=?", get_TrxName()); List list = query.setParameters(getAD_InfoWindow_ID()) diff --git a/org.adempiere.base/src/org/compiere/model/MPInstance.java b/org.adempiere.base/src/org/compiere/model/MPInstance.java index 26855eab54..9b6008d219 100644 --- a/org.adempiere.base/src/org/compiere/model/MPInstance.java +++ b/org.adempiere.base/src/org/compiere/model/MPInstance.java @@ -49,12 +49,12 @@ import org.osgi.service.event.Event; */ public class MPInstance extends X_AD_PInstance { - /** + /** * */ - private static final long serialVersionUID = -4047766735041088419L; - - public static final String ON_RUNNING_JOB_CHANGED_TOPIC = "onRunningJobChanged"; + private static final long serialVersionUID = 558778359873793799L; + + public static final String ON_RUNNING_JOB_CHANGED_TOPIC = "onRunningJobChanged"; private static CLogger s_log = CLogger.getCLogger (MPInstance.class); @@ -395,7 +395,7 @@ public class MPInstance extends X_AD_PInstance } // unnamed instances - int lastRunCount = MSysConfig.getIntValue("LASTRUN_RECORD_COUNT", 5, Env.getAD_Client_ID(ctx)); + int lastRunCount = MSysConfig.getIntValue(MSysConfig.LASTRUN_RECORD_COUNT, 5, Env.getAD_Client_ID(ctx)); if (lastRunCount > 0) { // using JDBC instead of Query for performance reasons, AD_PInstance can be huge String sql = "SELECT * FROM AD_PInstance " diff --git a/org.adempiere.base/src/org/compiere/model/MPayment.java b/org.adempiere.base/src/org/compiere/model/MPayment.java index 2469851197..4129b23b46 100644 --- a/org.adempiere.base/src/org/compiere/model/MPayment.java +++ b/org.adempiere.base/src/org/compiere/model/MPayment.java @@ -80,12 +80,10 @@ import org.compiere.util.ValueNamePair; public class MPayment extends X_C_Payment implements DocAction, ProcessCall, PaymentInterface { - - - /** - * - */ - private static final long serialVersionUID = 6200327948230438741L; + /** + * + */ + private static final long serialVersionUID = -3426445843281140181L; /** * Get Payments Of BPartner @@ -1625,7 +1623,7 @@ public class MPayment extends X_C_Payment sumPaymentAllocates = sumPaymentAllocates.add(pAlloc.getAmount()); if (getPayAmt().compareTo(sumPaymentAllocates) != 0) { if (isReceipt() && getPayAmt().compareTo(sumPaymentAllocates) < 0) { - if (MSysConfig.getBooleanValue("ALLOW_OVER_APPLIED_PAYMENT", false, Env.getAD_Client_ID(Env.getCtx()))) { + if (MSysConfig.getBooleanValue(MSysConfig.ALLOW_OVER_APPLIED_PAYMENT, false, Env.getAD_Client_ID(Env.getCtx()))) { return true; } } diff --git a/org.adempiere.base/src/org/compiere/model/MProduction.java b/org.adempiere.base/src/org/compiere/model/MProduction.java index 20a6766009..6826a6dbb5 100644 --- a/org.adempiere.base/src/org/compiere/model/MProduction.java +++ b/org.adempiere.base/src/org/compiere/model/MProduction.java @@ -26,7 +26,7 @@ public class MProduction extends X_M_Production implements DocAction { /** * */ - private static final long serialVersionUID = -9055468125493188165L; + private static final long serialVersionUID = 2222265936552140706L; /** * @@ -454,7 +454,7 @@ public class MProduction extends X_M_Production implements DocAction { if (!costsOK(M_Product_ID)) { msg = "Excessive difference in standard costs"; - if (MSysConfig.getBooleanValue("MFG_ValidateCostsDifferenceOnCreate", false, getAD_Client_ID())) { + if (MSysConfig.getBooleanValue(MSysConfig.MFG_ValidateCostsDifferenceOnCreate, false, getAD_Client_ID())) { return msg; } else { log.warning(msg); @@ -503,7 +503,7 @@ public class MProduction extends X_M_Production implements DocAction { { costPercentageDiff = Env.ZERO; String msg = "Could not retrieve costs"; - if (MSysConfig.getBooleanValue("MFG_ValidateCostsOnCreate", false, getAD_Client_ID())) { + if (MSysConfig.getBooleanValue(MSysConfig.MFG_ValidateCostsOnCreate, false, getAD_Client_ID())) { throw new AdempiereUserError(msg); } else { log.warning(msg); diff --git a/org.adempiere.base/src/org/compiere/model/MSysConfig.java b/org.adempiere.base/src/org/compiere/model/MSysConfig.java index 0e11db4059..a16e15b2a0 100644 --- a/org.adempiere.base/src/org/compiere/model/MSysConfig.java +++ b/org.adempiere.base/src/org/compiere/model/MSysConfig.java @@ -42,94 +42,102 @@ public class MSysConfig extends X_AD_SysConfig /** * */ - private static final long serialVersionUID = -2008818748067665365L; + private static final long serialVersionUID = 7850399904723862767L; - public final static String PDF_FONT_DIR = "PDF_FONT_DIR"; - public final static String TWOPACK_HANDLE_TRANSLATIONS = "2PACK_HANDLE_TRANSLATIONS"; - public static final String ZK_DESKTOP_CLASS = "ZK_DESKTOP_CLASS"; - public static final String CASH_AS_PAYMENT = "CASH_AS_PAYMENT"; - public static final String MAX_ACTIVITIES_IN_LIST = "MAX_ACTIVITIES_IN_LIST"; - public static final String ZK_ROOT_FOLDER_BROWSER = "ZK_ROOT_FOLDER_BROWSER"; - public static final String ZK_PAGING_SIZE = "ZK_PAGING_SIZE"; - public static final String ZK_GRID_EDIT_MODELESS = "ZK_GRID_EDIT_MODELESS"; - public static final String ZK_DASHBOARD_REFRESH_INTERVAL = "ZK_DASHBOARD_REFRESH_INTERVAL"; - public static final String RecentItems_MaxShown = "RecentItems_MaxShown"; - public static final String USE_EMAIL_FOR_LOGIN = "USE_EMAIL_FOR_LOGIN"; - public static final String LOGIN_SHOW_RESETPASSWORD = "LOGIN_SHOW_RESETPASSWORD"; - public static final String ALogin_ShowOneRole = "ALogin_ShowOneRole"; - public static final String ZK_BROWSER_ICON = "ZK_BROWSER_ICON"; - public static final String ZK_BROWSER_TITLE = "ZK_BROWSER_TITLE"; - public static final String ZK_LOGO_LARGE = "ZK_LOGO_LARGE"; - public static final String ZK_LOGO_SMALL = "ZK_LOGO_SMALL"; - public static final String WEBUI_LOGOURL = "WEBUI_LOGOURL"; - public static final String LOCATION_MAX_CITY_ROWS = "LOCATION_MAX_CITY_ROWS"; - public static final String ZK_REPORT_FORM_OUTPUT_TYPE = "ZK_REPORT_FORM_OUTPUT_TYPE"; - public static final String ZK_REPORT_TABLE_OUTPUT_TYPE = "ZK_REPORT_TABLE_OUTPUT_TYPE"; - public static final String MENU_INFOUPDATER_SLEEP_MS = "MENU_INFOUPDATER_SLEEP_MS"; - public static final String SYSCONFIG_INFO_DOUBLECLICKTOGGLESSELECTION = "SYSCONFIG_INFO_DOUBLECLICKTOGGLESSELECTION"; - public static final String SYSCONFIG_INFO_DEFAULTSELECTED = "SYSCONFIG_INFO_DEFAULTSELECTED"; - public static final String DICTIONARY_ID_USE_CENTRALIZED_ID = "DICTIONARY_ID_USE_CENTRALIZED_ID"; - public static final String PROJECT_ID_USE_CENTRALIZED_ID = "PROJECT_ID_USE_CENTRALIZED_ID"; - public static final String SYSTEM_NATIVE_SEQUENCE = "SYSTEM_NATIVE_SEQUENCE"; - public static final String START_VALUE_BPLOCATION_NAME = "START_VALUE_BPLOCATION_NAME"; - public static final String CLIENT_ACCOUNTING = "CLIENT_ACCOUNTING"; - public static final String CHECK_CREDIT_ON_PREPAY_ORDER = "CHECK_CREDIT_ON_PREPAY_ORDER"; - public static final String CHECK_CREDIT_ON_CASH_POS_ORDER = "CHECK_CREDIT_ON_CASH_POS_ORDER"; - public static final String Invoice_ReverseUseNewNumber = "Invoice_ReverseUseNewNumber"; - public static final String PROJECT_ID_COMMENTS = "PROJECT_ID_COMMENTS"; - public static final String DICTIONARY_ID_COMMENTS = "DICTIONARY_ID_COMMENTS"; - public static final String LOCATION_MAPS_URL_PREFIX = "LOCATION_MAPS_URL_PREFIX"; - public static final String LOCATION_MAPS_ROUTE_PREFIX = "LOCATION_MAPS_ROUTE_PREFIX"; - public static final String LOCATION_MAPS_SOURCE_ADDRESS = "LOCATION_MAPS_SOURCE_ADDRESS"; - public static final String LOCATION_MAPS_DESTINATION_ADDRESS = "LOCATION_MAPS_DESTINATION_ADDRESS"; - public static final String PAYMENT_OVERWRITE_DOCUMENTNO_WITH_CREDIT_CARD = "PAYMENT_OVERWRITE_DOCUMENTNO_WITH_CREDIT_CARD"; - public static final String PAYMENT_OVERWRITE_DOCUMENTNO_WITH_CHECK_ON_PAYMENT = "PAYMENT_OVERWRITE_DOCUMENTNO_WITH_CHECK_ON_PAYMENT"; - public static final String PAYMENT_OVERWRITE_DOCUMENTNO_WITH_CHECK_ON_RECEIPT = "PAYMENT_OVERWRITE_DOCUMENTNO_WITH_CHECK_ON_RECEIPT"; - public static final String RecentItems_MaxSaved = "RecentItems_MaxSaved"; - public static final String DICTIONARY_ID_WEBSITE = "DICTIONARY_ID_WEBSITE"; - public static final String DICTIONARY_ID_USER = "DICTIONARY_ID_USER"; - public static final String DICTIONARY_ID_PASSWORD = "DICTIONARY_ID_PASSWORD"; - public static final String PROJECT_ID_WEBSITE = "PROJECT_ID_WEBSITE"; - public static final String PROJECT_ID_USER = "PROJECT_ID_USER"; - public static final String PROJECT_ID_PASSWORD = "PROJECT_ID_PASSWORD"; - public static final String PROJECT_ID_PROJECT = "PROJECT_ID_PROJECT"; - public static final String ZK_LOGIN_ALLOW_REMEMBER_ME = "ZK_LOGIN_ALLOW_REMEMBER_ME"; - public static final String SWING_LOGIN_ALLOW_REMEMBER_ME = "SWING_LOGIN_ALLOW_REMEMBER_ME"; - public static final String USER_PASSWORD_HASH = "USER_PASSWORD_HASH"; - public static final String USER_LOCKING_MAX_ACCOUNT_LOCK_MINUTES = "USER_LOCKING_MAX_ACCOUNT_LOCK_MINUTES"; - public static final String USER_LOCKING_MAX_LOGIN_ATTEMPT = "USER_LOCKING_MAX_LOGIN_ATTEMPT"; - public static final String USER_LOCKING_MAX_INACTIVE_PERIOD_DAY = "USER_LOCKING_MAX_INACTIVE_PERIOD_DAY"; - public static final String USER_LOCKING_MAX_PASSWORD_AGE_DAY = "USER_LOCKING_MAX_PASSWORD_AGE_DAY"; - public static final String CHANGE_PASSWORD_MUST_DIFFER = "CHANGE_PASSWORD_MUST_DIFFER"; - public static final String ProductUOMConversionUOMValidate = "ProductUOMConversionUOMValidate"; - public static final String ProductUOMConversionRateValidate = "ProductUOMConversionRateValidate"; - public static final String SYSTEM_INSERT_CHANGELOG = "SYSTEM_INSERT_CHANGELOG"; - public static final String REPORT_SWAP_MAX_ROWS = "REPORT_SWAP_MAX_ROWS"; - public static final String JASPER_SWAP_MAX_PAGES = "JASPER_SWAP_MAX_PAGES"; - public static final String ALERT_SEND_ATTACHMENT_AS_XLS = "ALERT_SEND_ATTACHMENT_AS_XLS"; - public static final String SWING_OVERRIDE_TEXT_AREA_BEHAVIOUR = "SWING_OVERRIDE_TEXT_AREA_BEHAVIOUR"; - public static final String MAIL_SEND_BCC_TO_ADDRESS = "MAIL_SEND_BCC_TO_ADDRESS"; - public static final String MAIL_SEND_BCC_TO_FROM = "MAIL_SEND_BCC_TO_FROM"; - public static final String MAIL_SEND_CREDENTIALS = "MAIL_SEND_CREDENTIALS"; - public static final String REAL_TIME_POS = "REAL_TIME_POS"; - public static final String SHIPPING_DEFAULT_WEIGHT_PER_PACKAGE = "SHIPPING_DEFAULT_WEIGHT_PER_PACKAGE"; - public static final String SHIPPING_SAVE_REQUEST_RESPONSE_LOG = "SHIPPING_SAVE_REQUEST_RESPONSE_LOG"; - public static final String DOCACTIONBUTTON_SHOWACTIONNAME = "DOCACTIONBUTTON_SHOWACTIONNAME"; - public static final String ZK_MAX_UPLOAD_SIZE = "ZK_MAX_UPLOAD_SIZE"; - public static final String CALENDAR_ALTERNATE_TIMEZONE = "CALENDAR_ALTERNATE_TIMEZONE"; - public static final String ZK_REPORT_JASPER_OUTPUT_TYPE = "ZK_REPORT_JASPER_OUTPUT_TYPE"; - public static final String ADDRESS_VALIDATION = "ADDRESS_VALIDATION"; - public static final String TAX_SAVE_REQUEST_RESPONSE_LOG = "TAX_SAVE_REQUEST_RESPONSE_LOG"; - public static final String ADDRESS_SAVE_REQUEST_RESPONSE_LOG = "ADDRESS_SAVE_REQUEST_RESPONSE_LOG"; - public static final String VALIDATE_MATCHING_TO_ORDERED_QTY = "VALIDATE_MATCHING_TO_ORDERED_QTY"; - - public static final String BACKGROUND_JOB_ALLOWED = "BACKGROUND_JOB_ALLOWED"; - public static final String BACKGROUND_JOB_BY_DEFAULT = "BACKGROUND_JOB_BY_DEFAULT"; - public static final String BACKGROUND_JOB_MAX_IN_SYSTEM = "BACKGROUND_JOB_MAX_IN_SYSTEM"; - public static final String BACKGROUND_JOB_MAX_PER_CLIENT = "BACKGROUND_JOB_MAX_PER_CLIENT"; - public static final String BACKGROUND_JOB_MAX_PER_USER = "BACKGROUND_JOB_MAX_PER_USER"; - public static final String DPVIEWS_SHOWINFOACCOUNT = "DPViews_ShowInfoAccount"; - public static final String DPVIEWS_SHOWINFOSCHEDULE = "DPViews_ShowInfoSchedule"; + public static final String ADDRESS_SAVE_REQUEST_RESPONSE_LOG = "ADDRESS_SAVE_REQUEST_RESPONSE_LOG"; + public static final String ADDRESS_VALIDATION = "ADDRESS_VALIDATION"; + public static final String ALERT_SEND_ATTACHMENT_AS_XLS = "ALERT_SEND_ATTACHMENT_AS_XLS"; + public static final String ALLOW_APPLY_PAYMENT_TO_CREDITMEMO = "ALLOW_APPLY_PAYMENT_TO_CREDITMEMO"; + public static final String ALLOW_OVER_APPLIED_PAYMENT = "ALLOW_OVER_APPLIED_PAYMENT"; + public static final String ALogin_ShowOneRole = "ALogin_ShowOneRole"; + public static final String BACKGROUND_JOB_ALLOWED = "BACKGROUND_JOB_ALLOWED"; + public static final String BACKGROUND_JOB_BY_DEFAULT = "BACKGROUND_JOB_BY_DEFAULT"; + public static final String BACKGROUND_JOB_MAX_IN_SYSTEM = "BACKGROUND_JOB_MAX_IN_SYSTEM"; + public static final String BACKGROUND_JOB_MAX_PER_CLIENT = "BACKGROUND_JOB_MAX_PER_CLIENT"; + public static final String BACKGROUND_JOB_MAX_PER_USER = "BACKGROUND_JOB_MAX_PER_USER"; + public static final String CALENDAR_ALTERNATE_TIMEZONE = "CALENDAR_ALTERNATE_TIMEZONE"; + public static final String CASH_AS_PAYMENT = "CASH_AS_PAYMENT"; + public static final String CHANGE_PASSWORD_MUST_DIFFER = "CHANGE_PASSWORD_MUST_DIFFER"; + public static final String CHECK_CREDIT_ON_CASH_POS_ORDER = "CHECK_CREDIT_ON_CASH_POS_ORDER"; + public static final String CHECK_CREDIT_ON_PREPAY_ORDER = "CHECK_CREDIT_ON_PREPAY_ORDER"; + public static final String CLIENT_ACCOUNTING = "CLIENT_ACCOUNTING"; + public static final String DICTIONARY_ID_COMMENTS = "DICTIONARY_ID_COMMENTS"; + public static final String DICTIONARY_ID_PASSWORD = "DICTIONARY_ID_PASSWORD"; + public static final String DICTIONARY_ID_USE_CENTRALIZED_ID = "DICTIONARY_ID_USE_CENTRALIZED_ID"; + public static final String DICTIONARY_ID_USER = "DICTIONARY_ID_USER"; + public static final String DICTIONARY_ID_WEBSITE = "DICTIONARY_ID_WEBSITE"; + public static final String DOCACTIONBUTTON_SHOWACTIONNAME = "DOCACTIONBUTTON_SHOWACTIONNAME"; + public static final String DPVIEWS_SHOWINFOACCOUNT = "DPViews_ShowInfoAccount"; + public static final String DPVIEWS_SHOWINFOSCHEDULE = "DPViews_ShowInfoSchedule"; + public static final String Invoice_ReverseUseNewNumber = "Invoice_ReverseUseNewNumber"; + public static final String JASPER_SWAP_MAX_PAGES = "JASPER_SWAP_MAX_PAGES"; + public static final String LASTRUN_RECORD_COUNT = "LASTRUN_RECORD_COUNT"; + public static final String LOCATION_MAPS_DESTINATION_ADDRESS = "LOCATION_MAPS_DESTINATION_ADDRESS"; + public static final String LOCATION_MAPS_ROUTE_PREFIX = "LOCATION_MAPS_ROUTE_PREFIX"; + public static final String LOCATION_MAPS_SOURCE_ADDRESS = "LOCATION_MAPS_SOURCE_ADDRESS"; + public static final String LOCATION_MAPS_URL_PREFIX = "LOCATION_MAPS_URL_PREFIX"; + public static final String LOCATION_MAX_CITY_ROWS = "LOCATION_MAX_CITY_ROWS"; + public static final String LOGIN_HELP_URL = "LOGIN_HELP_URL"; + public static final String LOGIN_SHOW_RESETPASSWORD = "LOGIN_SHOW_RESETPASSWORD"; + public static final String MAIL_SEND_BCC_TO_ADDRESS = "MAIL_SEND_BCC_TO_ADDRESS"; + public static final String MAIL_SEND_BCC_TO_FROM = "MAIL_SEND_BCC_TO_FROM"; + public static final String MAIL_SEND_CREDENTIALS = "MAIL_SEND_CREDENTIALS"; + public static final String MAX_ACTIVITIES_IN_LIST = "MAX_ACTIVITIES_IN_LIST"; + public static final String MENU_INFOUPDATER_SLEEP_MS = "MENU_INFOUPDATER_SLEEP_MS"; + public static final String MFG_ValidateCostsDifferenceOnCreate = "MFG_ValidateCostsDifferenceOnCreate"; + public static final String MFG_ValidateCostsOnCreate = "MFG_ValidateCostsOnCreate"; + public static final String PAYMENT_OVERWRITE_DOCUMENTNO_WITH_CHECK_ON_PAYMENT = "PAYMENT_OVERWRITE_DOCUMENTNO_WITH_CHECK_ON_PAYMENT"; + public static final String PAYMENT_OVERWRITE_DOCUMENTNO_WITH_CHECK_ON_RECEIPT = "PAYMENT_OVERWRITE_DOCUMENTNO_WITH_CHECK_ON_RECEIPT"; + public static final String PAYMENT_OVERWRITE_DOCUMENTNO_WITH_CREDIT_CARD = "PAYMENT_OVERWRITE_DOCUMENTNO_WITH_CREDIT_CARD"; + public static final String PDF_FONT_DIR = "PDF_FONT_DIR"; + public static final String ProductUOMConversionRateValidate = "ProductUOMConversionRateValidate"; + public static final String ProductUOMConversionUOMValidate = "ProductUOMConversionUOMValidate"; + public static final String PROJECT_ID_COMMENTS = "PROJECT_ID_COMMENTS"; + public static final String PROJECT_ID_PASSWORD = "PROJECT_ID_PASSWORD"; + public static final String PROJECT_ID_PROJECT = "PROJECT_ID_PROJECT"; + public static final String PROJECT_ID_USE_CENTRALIZED_ID = "PROJECT_ID_USE_CENTRALIZED_ID"; + public static final String PROJECT_ID_USER = "PROJECT_ID_USER"; + public static final String PROJECT_ID_WEBSITE = "PROJECT_ID_WEBSITE"; + public static final String REAL_TIME_POS = "REAL_TIME_POS"; + public static final String RecentItems_MaxSaved = "RecentItems_MaxSaved"; + public static final String RecentItems_MaxShown = "RecentItems_MaxShown"; + public static final String REPORT_SWAP_MAX_ROWS = "REPORT_SWAP_MAX_ROWS"; + public static final String SHIPPING_DEFAULT_WEIGHT_PER_PACKAGE = "SHIPPING_DEFAULT_WEIGHT_PER_PACKAGE"; + public static final String SHIPPING_SAVE_REQUEST_RESPONSE_LOG = "SHIPPING_SAVE_REQUEST_RESPONSE_LOG"; + public static final String START_VALUE_BPLOCATION_NAME = "START_VALUE_BPLOCATION_NAME"; + public static final String SWING_LOGIN_ALLOW_REMEMBER_ME = "SWING_LOGIN_ALLOW_REMEMBER_ME"; + public static final String SWING_OVERRIDE_TEXT_AREA_BEHAVIOUR = "SWING_OVERRIDE_TEXT_AREA_BEHAVIOUR"; + public static final String SYSCONFIG_INFO_DEFAULTSELECTED = "SYSCONFIG_INFO_DEFAULTSELECTED"; + public static final String SYSCONFIG_INFO_DOUBLECLICKTOGGLESSELECTION = "SYSCONFIG_INFO_DOUBLECLICKTOGGLESSELECTION"; + public static final String SYSTEM_IN_MAINTENANCE_MODE = "SYSTEM_IN_MAINTENANCE_MODE"; + public static final String SYSTEM_INSERT_CHANGELOG = "SYSTEM_INSERT_CHANGELOG"; + public static final String SYSTEM_NATIVE_SEQUENCE = "SYSTEM_NATIVE_SEQUENCE"; + public static final String TAX_SAVE_REQUEST_RESPONSE_LOG = "TAX_SAVE_REQUEST_RESPONSE_LOG"; + public static final String TWOPACK_HANDLE_TRANSLATIONS = "2PACK_HANDLE_TRANSLATIONS"; + public static final String USE_EMAIL_FOR_LOGIN = "USE_EMAIL_FOR_LOGIN"; + public static final String USER_LOCKING_MAX_ACCOUNT_LOCK_MINUTES = "USER_LOCKING_MAX_ACCOUNT_LOCK_MINUTES"; + public static final String USER_LOCKING_MAX_INACTIVE_PERIOD_DAY = "USER_LOCKING_MAX_INACTIVE_PERIOD_DAY"; + public static final String USER_LOCKING_MAX_LOGIN_ATTEMPT = "USER_LOCKING_MAX_LOGIN_ATTEMPT"; + public static final String USER_LOCKING_MAX_PASSWORD_AGE_DAY = "USER_LOCKING_MAX_PASSWORD_AGE_DAY"; + public static final String USER_PASSWORD_HASH = "USER_PASSWORD_HASH"; + public static final String VALIDATE_MATCHING_TO_ORDERED_QTY = "VALIDATE_MATCHING_TO_ORDERED_QTY"; + public static final String WEBUI_LOGOURL = "WEBUI_LOGOURL"; + public static final String ZK_BROWSER_ICON = "ZK_BROWSER_ICON"; + public static final String ZK_BROWSER_TITLE = "ZK_BROWSER_TITLE"; + public static final String ZK_BUTTON_STYLE = "ZK_BUTTON_STYLE"; + public static final String ZK_DASHBOARD_REFRESH_INTERVAL = "ZK_DASHBOARD_REFRESH_INTERVAL"; + public static final String ZK_DESKTOP_CLASS = "ZK_DESKTOP_CLASS"; + public static final String ZK_GRID_EDIT_MODELESS = "ZK_GRID_EDIT_MODELESS"; + public static final String ZK_LOGIN_ALLOW_REMEMBER_ME = "ZK_LOGIN_ALLOW_REMEMBER_ME"; + public static final String ZK_LOGO_LARGE = "ZK_LOGO_LARGE"; + public static final String ZK_LOGO_SMALL = "ZK_LOGO_SMALL"; + public static final String ZK_MAX_UPLOAD_SIZE = "ZK_MAX_UPLOAD_SIZE"; + public static final String ZK_PAGING_SIZE = "ZK_PAGING_SIZE"; + public static final String ZK_REPORT_FORM_OUTPUT_TYPE = "ZK_REPORT_FORM_OUTPUT_TYPE"; + public static final String ZK_REPORT_JASPER_OUTPUT_TYPE = "ZK_REPORT_JASPER_OUTPUT_TYPE"; + public static final String ZK_REPORT_TABLE_OUTPUT_TYPE = "ZK_REPORT_TABLE_OUTPUT_TYPE"; + public static final String ZK_ROOT_FOLDER_BROWSER = "ZK_ROOT_FOLDER_BROWSER"; + public static final String ZK_THEME = "ZK_THEME"; /** * Standard Constructor diff --git a/org.adempiere.base/src/org/compiere/model/X_AD_InfoProcess.java b/org.adempiere.base/src/org/compiere/model/X_AD_InfoProcess.java new file mode 100644 index 0000000000..17f83277af --- /dev/null +++ b/org.adempiere.base/src/org/compiere/model/X_AD_InfoProcess.java @@ -0,0 +1,239 @@ +/****************************************************************************** + * Product: iDempiere ERP & CRM Smart Business Solution * + * Copyright (C) 1999-2012 ComPiere, Inc. All Rights Reserved. * + * This program is free software, you can redistribute it and/or modify it * + * under the terms version 2 of the GNU General Public License as published * + * by the Free Software Foundation. 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., * + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * + * For the text or an alternative of this public license, you may reach us * + * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * + * or via info@compiere.org or http://www.compiere.org/license.html * + *****************************************************************************/ +/** Generated Model - DO NOT CHANGE */ +package org.compiere.model; + +import java.sql.ResultSet; +import java.util.Properties; +import org.compiere.util.KeyNamePair; + +/** Generated Model for AD_InfoProcess + * @author iDempiere (generated) + * @version Release 2.0 - $Id$ */ +public class X_AD_InfoProcess extends PO implements I_AD_InfoProcess, I_Persistent +{ + + /** + * + */ + private static final long serialVersionUID = 20140529L; + + /** Standard Constructor */ + public X_AD_InfoProcess (Properties ctx, int AD_InfoProcess_ID, String trxName) + { + super (ctx, AD_InfoProcess_ID, trxName); + /** if (AD_InfoProcess_ID == 0) + { + setAD_InfoProcess_ID (0); + setAD_InfoProcess_UU (null); + setAD_Process_ID (0); + setLayoutType (null); +// B + setSeqNo (0); +// @SQL=SELECT NVL(MAX(SeqNo),0)+10 AS DefaultValue FROM AD_InfoProcess WHERE AD_InfoWindow_ID=@AD_InfoWindow_ID@ + } */ + } + + /** Load Constructor */ + public X_AD_InfoProcess (Properties ctx, ResultSet rs, String trxName) + { + super (ctx, rs, trxName); + } + + /** AccessLevel + * @return 4 - System + */ + protected int get_AccessLevel() + { + return accessLevel.intValue(); + } + + /** Load Meta Data */ + protected POInfo initPO (Properties ctx) + { + POInfo poi = POInfo.getPOInfo (ctx, Table_ID, get_TrxName()); + return poi; + } + + public String toString() + { + StringBuffer sb = new StringBuffer ("X_AD_InfoProcess[") + .append(get_ID()).append("]"); + return sb.toString(); + } + + /** Set Info Process. + @param AD_InfoProcess_ID Info Process */ + public void setAD_InfoProcess_ID (int AD_InfoProcess_ID) + { + if (AD_InfoProcess_ID < 1) + set_ValueNoCheck (COLUMNNAME_AD_InfoProcess_ID, null); + else + set_ValueNoCheck (COLUMNNAME_AD_InfoProcess_ID, Integer.valueOf(AD_InfoProcess_ID)); + } + + /** Get Info Process. + @return Info Process */ + public int getAD_InfoProcess_ID () + { + Integer ii = (Integer)get_Value(COLUMNNAME_AD_InfoProcess_ID); + if (ii == null) + return 0; + return ii.intValue(); + } + + /** Set AD_InfoProcess_UU. + @param AD_InfoProcess_UU AD_InfoProcess_UU */ + public void setAD_InfoProcess_UU (String AD_InfoProcess_UU) + { + set_ValueNoCheck (COLUMNNAME_AD_InfoProcess_UU, AD_InfoProcess_UU); + } + + /** Get AD_InfoProcess_UU. + @return AD_InfoProcess_UU */ + public String getAD_InfoProcess_UU () + { + return (String)get_Value(COLUMNNAME_AD_InfoProcess_UU); + } + + public org.compiere.model.I_AD_InfoWindow getAD_InfoWindow() throws RuntimeException + { + return (org.compiere.model.I_AD_InfoWindow)MTable.get(getCtx(), org.compiere.model.I_AD_InfoWindow.Table_Name) + .getPO(getAD_InfoWindow_ID(), get_TrxName()); } + + /** Set Info Window. + @param AD_InfoWindow_ID + Info and search/select Window + */ + public void setAD_InfoWindow_ID (int AD_InfoWindow_ID) + { + if (AD_InfoWindow_ID < 1) + set_ValueNoCheck (COLUMNNAME_AD_InfoWindow_ID, null); + else + set_ValueNoCheck (COLUMNNAME_AD_InfoWindow_ID, Integer.valueOf(AD_InfoWindow_ID)); + } + + /** Get Info Window. + @return Info and search/select Window + */ + public int getAD_InfoWindow_ID () + { + Integer ii = (Integer)get_Value(COLUMNNAME_AD_InfoWindow_ID); + if (ii == null) + return 0; + return ii.intValue(); + } + + public org.compiere.model.I_AD_Process getAD_Process() throws RuntimeException + { + return (org.compiere.model.I_AD_Process)MTable.get(getCtx(), org.compiere.model.I_AD_Process.Table_Name) + .getPO(getAD_Process_ID(), get_TrxName()); } + + /** Set Process. + @param AD_Process_ID + Process or Report + */ + public void setAD_Process_ID (int AD_Process_ID) + { + if (AD_Process_ID < 1) + set_Value (COLUMNNAME_AD_Process_ID, null); + else + set_Value (COLUMNNAME_AD_Process_ID, Integer.valueOf(AD_Process_ID)); + } + + /** Get Process. + @return Process or Report + */ + public int getAD_Process_ID () + { + Integer ii = (Integer)get_Value(COLUMNNAME_AD_Process_ID); + if (ii == null) + return 0; + return ii.intValue(); + } + + /** Get Record ID/ColumnName + @return ID/ColumnName pair + */ + public KeyNamePair getKeyNamePair() + { + return new KeyNamePair(get_ID(), String.valueOf(getAD_Process_ID())); + } + + /** Set Image URL. + @param ImageURL + URL of image + */ + public void setImageURL (String ImageURL) + { + set_Value (COLUMNNAME_ImageURL, ImageURL); + } + + /** Get Image URL. + @return URL of image + */ + public String getImageURL () + { + return (String)get_Value(COLUMNNAME_ImageURL); + } + + /** LayoutType AD_Reference_ID=200083 */ + public static final int LAYOUTTYPE_AD_Reference_ID=200083; + /** Button = B */ + public static final String LAYOUTTYPE_Button = "B"; + /** Menu = M */ + public static final String LAYOUTTYPE_Menu = "M"; + /** List = L */ + public static final String LAYOUTTYPE_List = "L"; + /** Set LayoutType. + @param LayoutType + Layout type of info process + */ + public void setLayoutType (String LayoutType) + { + + set_Value (COLUMNNAME_LayoutType, LayoutType); + } + + /** Get LayoutType. + @return Layout type of info process + */ + public String getLayoutType () + { + return (String)get_Value(COLUMNNAME_LayoutType); + } + + /** Set Sequence. + @param SeqNo + Method of ordering records; lowest number comes first + */ + public void setSeqNo (int SeqNo) + { + set_Value (COLUMNNAME_SeqNo, Integer.valueOf(SeqNo)); + } + + /** Get Sequence. + @return Method of ordering records; lowest number comes first + */ + public int getSeqNo () + { + Integer ii = (Integer)get_Value(COLUMNNAME_SeqNo); + if (ii == null) + return 0; + return ii.intValue(); + } +} \ No newline at end of file diff --git a/org.adempiere.base/src/org/compiere/model/X_AD_InfoWindow.java b/org.adempiere.base/src/org/compiere/model/X_AD_InfoWindow.java index 0a9ec8c814..8d8d8efc40 100644 --- a/org.adempiere.base/src/org/compiere/model/X_AD_InfoWindow.java +++ b/org.adempiere.base/src/org/compiere/model/X_AD_InfoWindow.java @@ -30,7 +30,7 @@ public class X_AD_InfoWindow extends PO implements I_AD_InfoWindow, I_Persistent /** * */ - private static final long serialVersionUID = 20140516L; + private static final long serialVersionUID = 20140528L; /** Standard Constructor */ public X_AD_InfoWindow (Properties ctx, int AD_InfoWindow_ID, String trxName) @@ -147,34 +147,6 @@ public class X_AD_InfoWindow extends PO implements I_AD_InfoWindow, I_Persistent return (String)get_Value(COLUMNNAME_AD_InfoWindow_UU); } - public org.compiere.model.I_AD_Process getAD_Process() throws RuntimeException - { - return (org.compiere.model.I_AD_Process)MTable.get(getCtx(), org.compiere.model.I_AD_Process.Table_Name) - .getPO(getAD_Process_ID(), get_TrxName()); } - - /** Set Process. - @param AD_Process_ID - Process or Report - */ - public void setAD_Process_ID (int AD_Process_ID) - { - if (AD_Process_ID < 1) - set_Value (COLUMNNAME_AD_Process_ID, null); - else - set_Value (COLUMNNAME_AD_Process_ID, Integer.valueOf(AD_Process_ID)); - } - - /** Get Process. - @return Process or Report - */ - public int getAD_Process_ID () - { - Integer ii = (Integer)get_Value(COLUMNNAME_AD_Process_ID); - if (ii == null) - return 0; - return ii.intValue(); - } - public org.compiere.model.I_AD_Table getAD_Table() throws RuntimeException { return (org.compiere.model.I_AD_Table)MTable.get(getCtx(), org.compiere.model.I_AD_Table.Table_Name) diff --git a/org.adempiere.base/src/org/compiere/util/Login.java b/org.adempiere.base/src/org/compiere/util/Login.java index cd3d5df0f8..583b09666f 100644 --- a/org.adempiere.base/src/org/compiere/util/Login.java +++ b/org.adempiere.base/src/org/compiere/util/Login.java @@ -772,7 +772,7 @@ public class Login // IDEMPIERE-1717 Maintenance mode if (! MRole.get(m_ctx, AD_Role_ID).isAccessAdvanced()) { - if (MSysConfig.getBooleanValue("SYSTEM_IN_MAINTENANCE_MODE", false, AD_Client_ID)) + if (MSysConfig.getBooleanValue(MSysConfig.SYSTEM_IN_MAINTENANCE_MODE, false, AD_Client_ID)) return Msg.getMsg(m_ctx, "SystemInMaintenance"); } diff --git a/org.adempiere.base/src/org/eevolution/process/BankTransfer.java b/org.adempiere.base/src/org/eevolution/process/BankTransfer.java index 15a7c416ba..fe3d20a235 100644 --- a/org.adempiere.base/src/org/eevolution/process/BankTransfer.java +++ b/org.adempiere.base/src/org/eevolution/process/BankTransfer.java @@ -26,6 +26,8 @@ import org.compiere.process.ProcessInfoParameter; import org.compiere.process.SvrProcess; import org.compiere.util.AdempiereUserError; import org.compiere.util.Env; +import org.compiere.util.Msg; +import org.compiere.util.Util; /** * Bank Transfer. Generate two Payments entry @@ -98,12 +100,12 @@ public class BankTransfer extends SvrProcess + " - Description="+p_Description+ " - Statement Date="+p_StatementDate+ " - Date Account="+p_DateAcct); + if (Env.getAD_Org_ID(getCtx()) == 0) + throw new AdempiereUserError(Msg.getMsg(getCtx(), "Org0NotAllowed")); + if (p_To_C_BankAccount_ID == 0 || p_From_C_BankAccount_ID == 0) throw new IllegalArgumentException("Banks required"); - if (p_DocumentNo == null || p_DocumentNo.length() == 0) - throw new IllegalArgumentException("Document No required"); - if (p_To_C_BankAccount_ID == p_From_C_BankAccount_ID) throw new AdempiereUserError ("Banks From and To must be different"); @@ -145,7 +147,8 @@ public class BankTransfer extends SvrProcess MPayment paymentBankFrom = new MPayment(getCtx(), 0 , get_TrxName()); paymentBankFrom.setC_BankAccount_ID(mBankFrom.getC_BankAccount_ID()); - paymentBankFrom.setDocumentNo(p_DocumentNo); + if (!Util.isEmpty(p_DocumentNo, true)) + paymentBankFrom.setDocumentNo(p_DocumentNo); paymentBankFrom.setDateAcct(p_DateAcct); paymentBankFrom.setDateTrx(p_StatementDate); paymentBankFrom.setTenderType(MPayment.TENDERTYPE_DirectDeposit); @@ -171,7 +174,8 @@ public class BankTransfer extends SvrProcess MPayment paymentBankTo = new MPayment(getCtx(), 0 , get_TrxName()); paymentBankTo.setC_BankAccount_ID(mBankTo.getC_BankAccount_ID()); - paymentBankTo.setDocumentNo(p_DocumentNo); + if (!Util.isEmpty(p_DocumentNo, true)) + paymentBankTo.setDocumentNo(p_DocumentNo); paymentBankTo.setDateAcct(p_DateAcct); paymentBankTo.setDateTrx(p_StatementDate); paymentBankTo.setTenderType(MPayment.TENDERTYPE_DirectDeposit); diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/AdempiereWebUI.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/AdempiereWebUI.java index 0628bc4b78..d008c7d65b 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/AdempiereWebUI.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/AdempiereWebUI.java @@ -83,7 +83,7 @@ public class AdempiereWebUI extends Window implements EventListener, IWeb public static final String APPLICATION_DESKTOP_KEY = "application.desktop"; - public static final String APP_NAME = "iDempiere"; + public static String APP_NAME = null; public static final String UID = "1.0.0"; diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/DefaultWebAppInit.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/DefaultWebAppInit.java new file mode 100644 index 0000000000..f9b56fd558 --- /dev/null +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/DefaultWebAppInit.java @@ -0,0 +1,200 @@ +/****************************************************************************** + * Product: Adempiere ERP & CRM Smart Business Solution * + * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * + * This program is free software; you can redistribute it and/or modify it * + * under the terms version 2 of the GNU General Public License as published * + * by the Free Software Foundation. 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., * + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * + * For the text or an alternative of this public license, you may reach us * + * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * + * or via info@compiere.org or http://www.compiere.org/license.html * + * Contributor(s) : Layda Salas - globalqss * + *****************************************************************************/ +package org.adempiere.webui; + +import org.adempiere.base.event.AbstractEventHandler; +import org.adempiere.base.event.EventManager; +import org.adempiere.base.event.IEventTopics; +import org.compiere.model.I_AD_SysConfig; +import org.compiere.model.MSysConfig; +import org.compiere.model.PO; +import org.compiere.model.X_AD_SysConfig; +import org.osgi.service.event.Event; +import org.zkoss.zk.ui.WebApp; +import org.zkoss.zk.ui.util.WebAppInit; + +/** + * Handle web app init event to sync config store in web config file and database + * @author hieplq + * + */ +public class DefaultWebAppInit implements WebAppInit { + + private static SystemConfigHandler systemConfigChangeHandler; + protected WebApp webApp = null; + + /** + * Register listen model change + */ + @Override + public void init(WebApp wapp) throws Exception { + this.webApp = wapp; + // save app name get from zk.xml to restore when delete app name in system config value + AdempiereWebUI.APP_NAME = this.webApp.getAppName(); + String appNameConfig = MSysConfig.getValue(MSysConfig.ZK_BROWSER_TITLE); + if (appNameConfig != null){ + this.webApp.setAppName(appNameConfig); + } + + createStaticListeners (); + + } + + /** + * register handle model change to event manage + * Current only init handle System config table + */ + private synchronized void createStaticListeners() { + if (systemConfigChangeHandler == null) { + systemConfigChangeHandler = new SystemConfigHandler(webApp); + systemConfigChangeHandler.bindEventManager(EventManager.getInstance()); + } + } + + /** + * Process modle event of table system config + * @author hieplq + * + */ + static class SystemConfigHandler extends AbstractEventHandler { + String IS_DELETE = "org.compiere.util.SystemConfigHandler.isDelete"; + protected WebApp webApp = null; + + /** + * cache WebApp for user late + * @param webApp + */ + public SystemConfigHandler (WebApp webApp){ + this.webApp = webApp; + } + + /** + * {@inheritDoc} + */ + @Override + protected void doHandleEvent(Event event) { + PO po = getPO(event); + // just track change and delete status. + // new, change, rename to = change => isDelete = false + // delete, rename from = delete => isDelete = true + int nameColumnIndex = po.get_ColumnIndex(I_AD_SysConfig.COLUMNNAME_Name); + int valueColumnIndex = po.get_ColumnIndex(I_AD_SysConfig.COLUMNNAME_Value); + + boolean isChangeValue = po.is_ValueChanged(valueColumnIndex); + boolean isChangeName = po.is_ValueChanged(nameColumnIndex); + + // delete, rename config (rename have same effect delete) + if (IEventTopics.PO_BEFORE_DELETE.equals(event.getTopic()) || + (IEventTopics.PO_BEFORE_CHANGE.equals(event.getTopic()) && isChangeName) + ){ + beforeDelete (po); + + // when change one record = delete a record + new a record + if (IEventTopics.PO_BEFORE_CHANGE.equals(event.getTopic()) && isChangeName){ + beforeChange (po); + } + return; + } + + // delete, rename config (rename have same effect delete) + if (IEventTopics.PO_AFTER_DELETE.equals(event.getTopic()) || + (IEventTopics.PO_AFTER_CHANGE.equals(event.getTopic()) && isChangeName) + ){ + afterDelete (po); + + // when change one record = delete a record + new a record + if (IEventTopics.PO_AFTER_CHANGE.equals(event.getTopic()) && isChangeName){ + afterChange(po); + } + return; + } + + // new, change value consider as change. change name is process with above not there + if (IEventTopics.PO_BEFORE_NEW.equals(event.getTopic()) || + (IEventTopics.PO_BEFORE_CHANGE.equals(event.getTopic()) && !isChangeName && isChangeValue)){ + beforeChange (po); + return; + } + + // new, change value consider as change. change name is process with above not there + if (IEventTopics.PO_AFTER_NEW.equals(event.getTopic()) || + (IEventTopics.PO_AFTER_CHANGE.equals(event.getTopic()) && !isChangeName && isChangeValue)){ + afterChange (po); + return; + } + } + + protected void beforeDelete(PO po) { + //TODO:save flag to file for case when insert data success but before sync with file config has error crash program + } + + /** + * Process when delete a configuration record + * @param po + */ + protected void afterDelete (PO po){ + if (po instanceof X_AD_SysConfig){ + // when delete ZK_BROWSER_TITLE, set web config to default value "Idempiere" + // user old value of name for correct meaning of record delete, change + if (MSysConfig.ZK_BROWSER_TITLE.equals(getOldValueOfName(po))){ + webApp.setAppName(AdempiereWebUI.APP_NAME); + } + } + } + + /** + * get old value of column name + * @param po + * @return + */ + protected String getOldValueOfName(PO po) { + int nameColumnIndex = po.get_ColumnIndex(I_AD_SysConfig.COLUMNNAME_Name); + return po.get_ValueOld(nameColumnIndex).toString(); + } + + protected void beforeChange (PO po){ + //TODO:save flag to file for case when insert data success but before sync with file config has error crash program + } + + /** + * sync value in web config with new value in db + * @param po + */ + protected void afterChange (PO po){ + if (po instanceof X_AD_SysConfig){ + // when change ZK_BROWSER_TITLE, set web config to new value + if (MSysConfig.ZK_BROWSER_TITLE.equals(((X_AD_SysConfig) po).getName())){ + String configAppname = ((X_AD_SysConfig) po).getValue(); + webApp.setAppName(configAppname); + } + } + } + + @Override + protected void initialize() { + registerTableEvent(IEventTopics.PO_AFTER_CHANGE, I_AD_SysConfig.Table_Name); + registerTableEvent(IEventTopics.PO_AFTER_NEW, I_AD_SysConfig.Table_Name); + registerTableEvent(IEventTopics.PO_AFTER_DELETE, I_AD_SysConfig.Table_Name); + + registerTableEvent(IEventTopics.PO_BEFORE_CHANGE, I_AD_SysConfig.Table_Name); + registerTableEvent(IEventTopics.PO_BEFORE_DELETE, I_AD_SysConfig.Table_Name); + registerTableEvent(IEventTopics.PO_BEFORE_NEW, I_AD_SysConfig.Table_Name); + } + } + +} diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/apps/AbstractProcessDialog.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/apps/AbstractProcessDialog.java index 1553b03b8d..d0331f7974 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/apps/AbstractProcessDialog.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/apps/AbstractProcessDialog.java @@ -42,6 +42,7 @@ import org.adempiere.webui.component.Row; import org.adempiere.webui.component.Rows; import org.adempiere.webui.component.Window; import org.adempiere.webui.editor.WTableDirEditor; +import org.adempiere.webui.event.DialogEvents; import org.adempiere.webui.process.WProcessInfo; import org.adempiere.webui.window.FDialog; import org.adempiere.webui.window.MultiFileDownloadDialog; @@ -82,8 +83,8 @@ public abstract class AbstractProcessDialog extends Window implements IProcessUI /** * */ - private static final long serialVersionUID = 2190456247109646320L; - + private static final long serialVersionUID = 761285757875594250L; + private static final String ON_COMPLETE = "onComplete"; private static final String ON_STATUS_UPDATE = "onStatusUpdate"; @@ -341,6 +342,7 @@ public abstract class AbstractProcessDialog extends Window implements IProcessUI public void runProcess() { + Events.sendEvent(DialogEvents.ON_BEFORE_RUN_PROCESS, this, null); future = Adempiere.getThreadPoolExecutor().submit(new DesktopRunnable(new ProcessDialogRunnable(null), getDesktop())); } diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/apps/ProcessModalDialog.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/apps/ProcessModalDialog.java index a8e1fb0d69..83c80d4ae8 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/apps/ProcessModalDialog.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/apps/ProcessModalDialog.java @@ -84,6 +84,7 @@ public class ProcessModalDialog extends AbstractProcessDialog implements EventLi if (listener != null) { addEventListener(ON_WINDOW_CLOSE, listener); + addEventListener(ON_BEFORE_RUN_PROCESS, listener); } log.info("Process=" + pi.getAD_Process_ID()); diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/component/ConfirmPanel.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/component/ConfirmPanel.java index 90f27f1264..09ff75ef3c 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/component/ConfirmPanel.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/component/ConfirmPanel.java @@ -23,6 +23,7 @@ import java.util.List; import java.util.Map; import org.adempiere.webui.factory.ButtonFactory; +import org.adempiere.webui.theme.ThemeManager; import org.zkoss.zk.ui.event.EventListener; import org.zkoss.zk.ui.event.Events; import org.zkoss.zul.Div; @@ -39,7 +40,8 @@ public final class ConfirmPanel extends Div /** * */ - private static final long serialVersionUID = -6050634074454659578L; + private static final long serialVersionUID = 3257542169107223645L; + /** Action String OK. */ public static final String A_OK = "Ok"; /** Action String Cancel. */ @@ -220,6 +222,8 @@ public final class ConfirmPanel extends Div // private Hlayout pnlBtnRight; private Hlayout pnlBtnLeft; + // IDEMPIERE-1334 center panel, contain all process button + private Hlayout pnlBtnCenter; /** * initialise components @@ -231,13 +235,36 @@ public final class ConfirmPanel extends Div pnlBtnRight = new Hlayout(); pnlBtnRight.setSclass("confirm-panel-right"); + // IDEMPIERE-1334 start + pnlBtnCenter = new Hlayout(); + pnlBtnCenter.setSclass("confirm-panel-center"); + // IDEMPIERE-1334 end + this.appendChild(pnlBtnLeft); + // IDEMPIERE-1334 + this.appendChild(pnlBtnCenter); this.appendChild(pnlBtnRight); this.setSclass("confirm-panel"); this.setVflex("min"); setId("confirmPanel"); } + /** + * IDEMPIERE-1334 + * add a process button into center panel + * @param btName + * @param imgName + * @return + */ + public Button addProcessButton (String btName, String imgName){ + Button btProcess = createButton(btName); + // replace default image with image set at info process + if (m_withImage && imgName != null && imgName.trim().length() > 0) + btProcess.setImage(ThemeManager.getThemeResource("images/" + imgName)); + addComponentsCenter(btProcess); + return btProcess; + } + /** * add button to the left side of the confirm panel * @param button button @@ -260,6 +287,26 @@ public final class ConfirmPanel extends Div pnlBtnRight.appendChild(button); } + /** + * IDEMPIERE-1334 + * add button to the center side of the confirm panel + * @param button button + */ + public void addComponentsCenter(Button button) + { + if (!buttonMap.containsKey(button.getId())) + buttonMap.put(button.getId(), button); + pnlBtnCenter.appendChild(button); + } + + /** + * Add combobox to center panel + * @param cbb + */ + public void addComponentsCenter(Combobox cbb){ + pnlBtnCenter.appendChild(cbb); + } + /** * return button of the specified id * @param id button id @@ -391,8 +438,12 @@ public final class ConfirmPanel extends Div { List list1 = pnlBtnLeft.getChildren(); List list2 = pnlBtnRight.getChildren(); + // IDEMPIERE-1334 + List list3 = pnlBtnCenter.getChildren(); Iterator iter1 = list1.iterator(); Iterator iter2 = list2.iterator(); + // IDEMPIERE-1334 + Iterator iter3 = list3.iterator(); while (iter1.hasNext()) { @@ -404,6 +455,13 @@ public final class ConfirmPanel extends Div Button button = (Button)iter2.next(); button.setEnabled(enabled); } + // IDEMPIERE-1334 start + while (iter3.hasNext()) + { + Button button = (Button)iter3.next(); + button.setEnabled(enabled); + } + // IDEMPIERE-1334 end } /** * add action listener on the existing buttons @@ -414,8 +472,12 @@ public final class ConfirmPanel extends Div { List list1 = pnlBtnLeft.getChildren(); List list2 = pnlBtnRight.getChildren(); + // IDEMPIERE-1334 + List list3 = pnlBtnCenter.getChildren(); Iterator iter1 = list1.iterator(); Iterator iter2 = list2.iterator(); + // IDEMPIERE-1334 + Iterator iter3 = list3.iterator(); while (iter1.hasNext()) { @@ -427,6 +489,13 @@ public final class ConfirmPanel extends Div Button button = (Button)iter2.next(); button.addEventListener(event, listener); } + // IDEMPIERE-1334 start + while (iter3.hasNext()) + { + Button button = (Button)iter3.next(); + button.addEventListener(event, listener); + } + // IDEMPIERE-1334 start } /** diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/component/WListbox.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/component/WListbox.java index 8063b1a82e..e4e8ce0c88 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/component/WListbox.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/component/WListbox.java @@ -55,11 +55,11 @@ import org.zkoss.zul.ListModel; * @author Sendy Yagambrum */ public class WListbox extends Listbox implements IMiniTable, TableValueChangeListener, WTableModelListener -{ +{ /** * */ - private static final long serialVersionUID = 8717707799347994189L; + private static final long serialVersionUID = -706774424788688953L; /** Logger. */ private static CLogger logger = CLogger.getCLogger(WListbox.class); @@ -745,22 +745,30 @@ public class WListbox extends Listbox implements IMiniTable, TableValueChangeLis */ public Integer getSelectedRowKey() { - int row = 0; - final int noSelection = -1; - final int noIndex = -1; - Object data; - if (m_layout == null) { throw new UnsupportedOperationException("Layout not defined"); } - row = getSelectedRow(); + int row = getSelectedRow(); + // make common function + return getRowKeyAt (row); + } // getSelectedRowKey + + /** + * IDEMPIERE-1334 + * get key of record at index + * @param index + * @return + */ + public Integer getRowKeyAt (int index){ // TODO factor out the two parts of this guard statement - if (row != noSelection && m_keyColumnIndex != noIndex) - { - data = getModel().getDataAt(row, m_keyColumnIndex); + if (index < 0 || m_keyColumnIndex < 0) + return null; + + + Object data = getModel().getDataAt(index, m_keyColumnIndex); if (data instanceof IDColumn) { @@ -770,10 +778,33 @@ public class WListbox extends Listbox implements IMiniTable, TableValueChangeLis { return (Integer)data; } + return null; } - return null; - } // getSelectedRowKey + /** + * IDEMPIERE-1334 + * deselect all current select, set all record have key in lsKey is selected + * when non key column just return + * @param lsKey + * @return + */ + public void setSelectedByKeys (List lsKey){ + // no key column because can't set selected, just return + if (m_keyColumnIndex < 0) + return; + ListModelTable model = getModel(); + List lsSelectedItem = new ArrayList (); + for (int index = 0; index < model.getSize(); index++){ + Integer key = getRowKeyAt(index); + if (key == null) + continue; + + if (lsKey.contains(key)){ + lsSelectedItem.add (model.getElementAt(index)); + } + } + model.setSelection(lsSelectedItem); + } public Integer getFirstRowKey() { @@ -787,19 +818,8 @@ public class WListbox extends Listbox implements IMiniTable, TableValueChangeLis return null; } - Object data = getModel().getDataAt(0, m_keyColumnIndex); - - if (data instanceof IDColumn) - { - data = ((IDColumn)data).getRecord_ID(); - } - - if (data instanceof Integer) - { - return (Integer)data; - } - - return null; + // make common function + return getRowKeyAt (0); } /** diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/dashboard/CalendarWindow.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/dashboard/CalendarWindow.java index 01f361c1f1..ef0ed371b0 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/dashboard/CalendarWindow.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/dashboard/CalendarWindow.java @@ -13,8 +13,6 @@ *****************************************************************************/ package org.adempiere.webui.dashboard; -import static org.compiere.model.MSysConfig.CALENDAR_ALTERNATE_TIMEZONE; - import java.awt.image.BufferedImage; import java.io.IOException; import java.math.BigDecimal; @@ -391,7 +389,7 @@ public class CalendarWindow extends Window implements EventListener, ITab private String getTimeZone() { - String alternateTimeZone = MSysConfig.getValue(CALENDAR_ALTERNATE_TIMEZONE, "Pacific Time=PST", Env.getAD_Client_ID(Env.getCtx())); + String alternateTimeZone = MSysConfig.getValue(MSysConfig.CALENDAR_ALTERNATE_TIMEZONE, "Pacific Time=PST", Env.getAD_Client_ID(Env.getCtx())); TimeZone defaultTimeZone = TimeZone.getDefault(); StringBuilder defaultTimeZoneName = new StringBuilder(defaultTimeZone.getDisplayName()); int defaultTimeZoneOffset = defaultTimeZone.getOffset(0) / 3600000; diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/desktop/DefaultDesktop.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/desktop/DefaultDesktop.java index 32db55c1e9..2d67994c88 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/desktop/DefaultDesktop.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/desktop/DefaultDesktop.java @@ -104,7 +104,7 @@ public class DefaultDesktop extends TabbedDesktop implements MenuListener, Seria /** * */ - private static final long serialVersionUID = -7495898481342426458L; + private static final long serialVersionUID = 4209181029836503344L; private static final String IMAGES_UPARROW_PNG = "images/collapse-header.png"; @@ -597,6 +597,11 @@ public class DefaultDesktop extends TabbedDesktop implements MenuListener, Seria helpController.renderToolTip(gridField); } + @Override + public void updateHelpTooltip(String hdr, String desc, String help, String otherContent) { + helpController.renderToolTip(hdr, desc, help, otherContent); + } + @Override public void updateHelpQuickInfo(GridTab gridTab) { helpController.renderQuickInfo(gridTab); diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/desktop/IDesktop.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/desktop/IDesktop.java index 287360407d..42fd01348f 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/desktop/IDesktop.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/desktop/IDesktop.java @@ -206,6 +206,8 @@ public interface IDesktop extends UIPart { public void updateHelpTooltip(GridField gridField); + public void updateHelpTooltip(String hdr, String desc, String help, String otherContent); + public void updateHelpQuickInfo(GridTab gridTab); public boolean isPendingWindow(); diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/event/DialogEvents.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/event/DialogEvents.java index 4373526d5b..d6fb0b7bb9 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/event/DialogEvents.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/event/DialogEvents.java @@ -25,4 +25,10 @@ public interface DialogEvents { */ public final static String ON_WINDOW_CLOSE = "onWindowClose"; + /** + * rise event before run process, other code can inject a long process in there + * example: at info window, save info to database before run process + */ + public final static String ON_BEFORE_RUN_PROCESS = "onBeforeRunProcess"; + } diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/factory/ButtonFactory.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/factory/ButtonFactory.java index 5d5e7a4976..3ed12cf91f 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/factory/ButtonFactory.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/factory/ButtonFactory.java @@ -28,13 +28,11 @@ import org.compiere.util.Util; */ public class ButtonFactory { - private static final String ZK_BUTTON_STYLE = "ZK_BUTTON_STYLE"; - /** * @return true if button should have text label */ public static final boolean isWithText() { - String type = MSysConfig.getValue(ZK_BUTTON_STYLE, "I"); + String type = MSysConfig.getValue(MSysConfig.ZK_BUTTON_STYLE, "I"); return type.indexOf("T") >= 0; } @@ -42,7 +40,7 @@ public class ButtonFactory { * @return true if button should include an image icon */ public static final boolean isWithImage() { - String type = MSysConfig.getValue(ZK_BUTTON_STYLE, "I"); + String type = MSysConfig.getValue(MSysConfig.ZK_BUTTON_STYLE, "I"); return type.indexOf("I") >= 0; } diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/info/InfoProductWindow.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/info/InfoProductWindow.java index 60306ea4e2..2566d20faf 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/info/InfoProductWindow.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/info/InfoProductWindow.java @@ -841,7 +841,7 @@ public class InfoProductWindow extends InfoWindow { @Override protected void prepareTable(ColumnInfo[] layout, String from, String where, String orderBy) { - if (getSelectedWarehouseId() > 0) + if (Util.isEmpty(orderBy) && getSelectedWarehouseId() > 0) { orderBy = "QtyAvailable DESC"; } diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/info/InfoWindow.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/info/InfoWindow.java index 1b91924ae0..073e580d83 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/info/InfoWindow.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/info/InfoWindow.java @@ -14,17 +14,20 @@ import java.util.Properties; import java.util.TreeMap; import java.util.logging.Level; +import org.adempiere.model.MInfoProcess; import org.adempiere.model.MInfoRelated; import org.adempiere.webui.AdempiereWebUI; import org.adempiere.webui.component.Borderlayout; import org.adempiere.webui.component.Button; import org.adempiere.webui.component.Column; import org.adempiere.webui.component.Columns; +import org.adempiere.webui.component.Combobox; import org.adempiere.webui.component.ConfirmPanel; import org.adempiere.webui.component.Grid; import org.adempiere.webui.component.GridFactory; import org.adempiere.webui.component.Label; import org.adempiere.webui.component.ListModelTable; +import org.adempiere.webui.component.Menupopup; import org.adempiere.webui.component.Row; import org.adempiere.webui.component.Rows; import org.adempiere.webui.component.Tab; @@ -40,6 +43,7 @@ import org.adempiere.webui.event.ValueChangeEvent; import org.adempiere.webui.event.ValueChangeListener; import org.adempiere.webui.panel.InfoPanel; import org.adempiere.webui.session.SessionManager; +import org.adempiere.webui.theme.ThemeManager; import org.adempiere.webui.window.FDialog; import org.compiere.minigrid.ColumnInfo; import org.compiere.minigrid.EmbedWinInfo; @@ -52,6 +56,7 @@ import org.compiere.model.MInfoColumn; import org.compiere.model.MInfoWindow; import org.compiere.model.MLookupFactory; import org.compiere.model.MLookupInfo; +import org.compiere.model.MProcess; import org.compiere.model.MRole; import org.compiere.model.MTable; import org.compiere.model.X_AD_InfoColumn; @@ -70,7 +75,12 @@ import org.zkoss.zk.ui.event.Events; import org.zkoss.zk.ui.event.SwipeEvent; import org.zkoss.zul.Center; import org.zkoss.zul.Checkbox; +import org.zkoss.zul.Comboitem; +import org.zkoss.zul.ComboitemRenderer; import org.zkoss.zul.Div; +import org.zkoss.zul.ListModel; +import org.zkoss.zul.ListModelList; +import org.zkoss.zul.Menuitem; import org.zkoss.zul.North; import org.zkoss.zul.Separator; import org.zkoss.zul.South; @@ -87,7 +97,7 @@ public class InfoWindow extends InfoPanel implements ValueChangeListener, EventL /** * */ - private static final long serialVersionUID = -5198550045241794995L; + private static final long serialVersionUID = 1958501982483183179L; protected Grid parameterGrid; private Borderlayout layout; @@ -111,6 +121,7 @@ public class InfoWindow extends InfoPanel implements ValueChangeListener, EventL protected String queryValue; private List gridFields; + private int AD_InfoWindow_ID; private Checkbox checkAND; /** @@ -140,18 +151,6 @@ public class InfoWindow extends InfoPanel implements ValueChangeListener, EventL this.queryValue = queryValue; this.AD_InfoWindow_ID = AD_InfoWindow_ID; - //red1 IDEMPIERE-1711 (Hengsin advised this minimal coding way) - infoWindow = new MInfoWindow(Env.getCtx(), AD_InfoWindow_ID, null); - if (infoWindow.getAD_Process_ID() > 0) - { - p_multipleSelection = true; - hasProcess = true; - Button b = confirmPanel.createButton(ConfirmPanel.A_PROCESS); - confirmPanel.addComponentsLeft(b); - b.addEventListener(Events.ON_CLICK, this); - } - //red1 -- end -- - //Xolali IDEMPIERE-1045 contentPanel.addActionListener(new EventListener() { public void onEvent(Event event) throws Exception { @@ -166,6 +165,16 @@ public class InfoWindow extends InfoPanel implements ValueChangeListener, EventL infoContext = new Properties(Env.getCtx()); p_loadedOK = loadInfoDefinition(); + + // make process button only in windown mode + if (!m_lookup){ + // IDEMPIERE-1334 + boolean haveProcess = initInfoProcess(); + // when have a process, force multi select mode + if (haveProcess) + p_multipleSelection = true; + } + loadInfoRelatedTabs(); if (loadedOK()) { if (isLookup()) { @@ -182,6 +191,117 @@ public class InfoWindow extends InfoPanel implements ValueChangeListener, EventL } } + /** + * IDEMPIERE-1334 + * load info process info + * layout each info process as button or dropdown item + * @return true when have process, false when no process + */ + protected boolean initInfoProcess() { + if (infoWindow == null){ + return false; + } + + MInfoProcess [] infoProcessList = infoWindow.getInfoProcess(false); + + // ** layout info process flow order (button list, drop down, dialog,...) + // each layout type in a loop to ensure this order + + // get info from process (name, help, des), set to name of button, item menu,... + MProcess process = null; + + // make list process button + for (MInfoProcess infoProcess : infoProcessList){ + // just add info process have layout is button + if (!MInfoProcess.LAYOUTTYPE_Button.equals(infoProcess.getLayoutType())){ + continue; + } + process = MProcess.get(Env.getCtx(), infoProcess.getAD_Process_ID()); + Button btProcess = confirmPanel.addProcessButton(process.get_Translation(MProcess.COLUMNNAME_Name), infoProcess.getImageURL()); + if (Util.isEmpty(infoProcess.getImageURL(), true)) { + btProcess.setImage(null); + btProcess.setLabel(process.get_Translation(MProcess.COLUMNNAME_Name)); + } + + // save process_id, handle event will use + btProcess.setAttribute(PROCESS_ID_KEY, new Integer(infoProcess.getAD_Process_ID())); + btProcess.addEventListener(Events.ON_CLICK, this); + // save info process to use in handle event + btProcess.setAttribute(ATT_INFO_PROCESS_KEY, process); + // update tooltip hepl when focus + btProcess.addEventListener(Events.ON_FOCUS, this); + btProcessList.add(btProcess); + } + + // filte just infoprocess have layout type is drop list for model of combobox + List infoProcessDropList = new ArrayList(); + for (MInfoProcess infoProcess : infoProcessList){ + if (!MInfoProcess.LAYOUTTYPE_List.equals(infoProcess.getLayoutType())){ + continue; + } + infoProcessDropList.add(infoProcess); + } + // make combobox contain list info process + if (infoProcessDropList.size() > 0){ + cbbProcess = new Combobox (); + ListModel infoProccessModel = new ListModelList(infoProcessDropList); + // render item, use name to display + cbbProcess.setItemRenderer(new ComboitemRenderer() { + public void render(Comboitem item, MInfoProcess data, int index){ + MProcess process = MProcess.get(Env.getCtx(), data.getAD_Process_ID()); + item.setValue(process); + item.setLabel(process.get_Translation(MProcess.COLUMNNAME_Name)); + if (!Util.isEmpty(data.getImageURL(), true)) { + item.setImage(ThemeManager.getThemeResource("images/" + data.getImageURL())); + } + } + }); + + // update tooltip hepl when select a item + cbbProcess.addEventListener(Events.ON_SELECT, this); + + cbbProcess.setModel(infoProccessModel); + confirmPanel.addComponentsCenter(cbbProcess); + + btCbbProcess = confirmPanel.addProcessButton(Msg.getMsg(Env.getCtx(), ConfirmPanel.A_PROCESS), null); + btCbbProcess.addEventListener(Events.ON_CLICK, this); + } + + // make menu button + Menupopup ipMenu = null; + for (MInfoProcess infoProcess : infoProcessList){ + // just add info process have layout is bt_menu + if (!MInfoProcess.LAYOUTTYPE_Menu.equals(infoProcess.getLayoutType())){ + continue; + } + + process = MProcess.get(Env.getCtx(), infoProcess.getAD_Process_ID()); + + // init popup menu + if (ipMenu == null){ + ipMenu = new Menupopup(); + ipMenu.setId("ipMenu"); + confirmPanel.appendChild(ipMenu); + + // init button to show menu + btMenuProcess = confirmPanel.addProcessButton("ProcessMenu", null); + btMenuProcess.setPopup("ipMenu, before_start"); + } + + // make menu item for each info process + Menuitem ipMenuItem = new Menuitem(); + ipMenuItem.setLabel(process.get_Translation(MProcess.COLUMNNAME_Name)); + if (!Util.isEmpty(infoProcess.getImageURL(), true)) { + ipMenuItem.setImage(ThemeManager.getThemeResource("images/" + infoProcess.getImageURL())); + } + ipMenuItem.setAttribute(PROCESS_ID_KEY, infoProcess.getAD_Process_ID()); + ipMenuItem.addEventListener(Events.ON_CLICK, this); + ipMenu.appendChild(ipMenuItem); + } + + return infoProcessList.length > 0; + } + private void processQueryValue() { for (int i = 0; i < identifiers.size(); i++) { WEditor editor = identifiers.get(i); @@ -398,6 +518,11 @@ public class InfoWindow extends InfoPanel implements ValueChangeListener, EventL { if (infoColumn.getAD_Reference_ID() == DisplayType.List) { + WEditor editor = null; + editor = WebEditorFactory.getEditor(gridFields.get(i), true); + editor.setMandatory(false); + editor.setReadWrite(false); + editorMap.put(infoColumn.getSelectClause(), editor); columnInfo = new ColumnInfo(infoColumn.get_Translation("Name"), infoColumn.getSelectClause(), ValueNamePair.class, (String)null); } else @@ -662,9 +787,23 @@ public class InfoWindow extends InfoPanel implements ValueChangeListener, EventL confirmPanel.getButton(ConfirmPanel.A_ZOOM).setVisible(hasZoom()); confirmPanel.getButton(ConfirmPanel.A_ZOOM).setDisabled(true); - if (hasProcess) - confirmPanel.getButton(ConfirmPanel.A_PROCESS).setDisabled(true); + // IDEMPIERE-1334 start when init all button process is disable because nothing record is selected + for (Button btProcess : btProcessList){ + btProcess.setDisabled(true); + } + if (btCbbProcess != null){ + btCbbProcess.setDisabled(true); + } + + if (btMenuProcess != null){ + btMenuProcess.setDisabled(true); + } + + if (cbbProcess != null){ + cbbProcess.setDisabled(true); + } + // IDEMPIERE-1334 end } protected void renderFooter(South south) { @@ -1010,11 +1149,6 @@ public class InfoWindow extends InfoPanel implements ValueChangeListener, EventL return !isLookup() && infoWindow != null && !MTable.get(Env.getCtx(), infoWindow.getAD_Table_ID()).isView(); } - @Override - protected boolean hasProcess() { //red1 IDEMPIERE-1711 to retain InfoWindow.process_ID > 0 as true - return hasProcess; - } - @Override public void valueChange(ValueChangeEvent evt) { if (evt != null && evt.getSource() instanceof WEditor) @@ -1059,7 +1193,13 @@ public class InfoWindow extends InfoPanel implements ValueChangeListener, EventL public void onEvent(Event event) { - if (event.getName().equals(Events.ON_FOCUS)) { + if (event.getName().equals(Events.ON_FOCUS) && event.getTarget() != null && + event.getTarget().getAttribute(ATT_INFO_PROCESS_KEY) != null){ + + MProcess process = (MProcess)event.getTarget().getAttribute(ATT_INFO_PROCESS_KEY); + SessionManager.getAppDesktop().updateHelpTooltip(process.get_Translation(MProcess.COLUMNNAME_Name), process.get_Translation(MProcess.COLUMNNAME_Description), process.get_Translation(MProcess.COLUMNNAME_Help), null); + } + else if (event.getName().equals(Events.ON_FOCUS)) { for (WEditor editor : editors) { if (editor.isComponentOfEditor(event.getTarget())) @@ -1068,6 +1208,15 @@ public class InfoWindow extends InfoPanel implements ValueChangeListener, EventL return; } } + }else if (event.getName().equals(Events.ON_SELECT) && event.getTarget().equals(cbbProcess)){ + // update help panel when change select item in combobox process + Comboitem selectedItem = cbbProcess.getSelectedItem(); + if (selectedItem != null && selectedItem.getValue() != null){ + MProcess selectedValue = (MProcess)selectedItem.getValue(); + + SessionManager.getAppDesktop().updateHelpTooltip(selectedValue.get_Translation(MProcess.COLUMNNAME_Name), selectedValue.get_Translation(MProcess.COLUMNNAME_Description), selectedValue.get_Translation(MProcess.COLUMNNAME_Help), null); + } + } else { @@ -1203,6 +1352,11 @@ public class InfoWindow extends InfoPanel implements ValueChangeListener, EventL { if (infoColumn.getAD_Reference_ID() == DisplayType.List) { + WEditor editor = null; + editor = WebEditorFactory.getEditor(getGridField(infoColumn), true); + editor.setMandatory(false); + editor.setReadWrite(false); + editorMap.put(infoColumn.getSelectClause(), editor); columnInfo = new ColumnInfo(infoColumn.get_Translation("Name"), infoColumn.getSelectClause(), ValueNamePair.class, (String)null); } else diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/HelpController.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/HelpController.java index 7ab457a29c..1bea3c5938 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/HelpController.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/HelpController.java @@ -183,11 +183,13 @@ public class HelpController sb.append("\n\n
\n"); if (hdr == null || hdr.trim().length() == 0){ - if (otherContent != null){ + if (otherContent == null){ + otherContent = Msg.getMsg(Env.getCtx(), "PlaceCursorIntoField"); + } + sb.append("("); sb.append (otherContent); sb.append (")"); - } }else{ sb.append(""); sb.append(hdr); diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/InfoPanel.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/InfoPanel.java index 7b273e0a23..3125ad2a6b 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/InfoPanel.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/InfoPanel.java @@ -32,17 +32,20 @@ import java.util.List; import java.util.Map; import java.util.Vector; import java.util.logging.Level; - import org.adempiere.webui.AdempiereWebUI; import org.adempiere.webui.apps.AEnv; import org.adempiere.webui.apps.BusyDialog; +import org.adempiere.webui.apps.ProcessModalDialog; import org.adempiere.webui.apps.WProcessCtl; +import org.adempiere.webui.component.Button; +import org.adempiere.webui.component.Combobox; import org.adempiere.webui.component.ConfirmPanel; import org.adempiere.webui.component.ListModelTable; import org.adempiere.webui.component.WListItemRenderer; import org.adempiere.webui.component.WListbox; import org.adempiere.webui.component.Window; import org.adempiere.webui.editor.WEditor; +import org.adempiere.webui.event.DialogEvents; import org.adempiere.webui.event.ValueChangeEvent; import org.adempiere.webui.event.ValueChangeListener; import org.adempiere.webui.event.WTableModelEvent; @@ -75,9 +78,11 @@ import org.zkoss.zk.ui.event.EventListener; import org.zkoss.zk.ui.event.Events; import org.zkoss.zk.ui.event.SelectEvent; import org.zkoss.zk.ui.util.Clients; +import org.zkoss.zul.Comboitem; import org.zkoss.zul.Listhead; import org.zkoss.zul.Listheader; import org.zkoss.zul.Listitem; +import org.zkoss.zul.Menuitem; import org.zkoss.zul.Paging; import org.zkoss.zul.event.ZulEvents; import org.zkoss.zul.ext.Sortable; @@ -99,11 +104,15 @@ public abstract class InfoPanel extends Window implements EventListener, /** * */ - private static final long serialVersionUID = 2823393272482373014L; + private static final long serialVersionUID = 7396541753653210881L; private final static int PAGE_SIZE = 100; - protected boolean hasProcess = false; + protected List