Merge development ( 10289 ) into zk7 ( 10252 ) branch

This commit is contained in:
Heng Sin Low 2014-04-03 09:17:58 +08:00
commit fa6541ff10
92 changed files with 10495 additions and 883 deletions

View File

@ -33,6 +33,8 @@ SELECT C_InvoicePaySchedule_ID, DueAmt FROM C_InvoicePaySchedule WHERE C_Invoice
************************************************************************/ ************************************************************************/
AS AS
v_Currency_ID NUMBER(10); v_Currency_ID NUMBER(10);
v_Precision NUMBER := 0;
v_Min NUMBER := 0;
v_TotalOpenAmt NUMBER := 0; v_TotalOpenAmt NUMBER := 0;
v_PaidAmt NUMBER := 0; v_PaidAmt NUMBER := 0;
v_Remaining NUMBER := 0; v_Remaining NUMBER := 0;
@ -70,6 +72,13 @@ BEGIN
END; END;
-- DBMS_OUTPUT.PUT_LINE('== C_Invoice_ID=' || p_C_Invoice_ID || ', Total=' || v_TotalOpenAmt || ', AP=' || v_MultiplierAP || ', CM=' || v_MultiplierCM); -- 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 POWER(1/10,v_Precision) INTO v_Min FROM DUAL;
-- Calculate Allocated Amount -- Calculate Allocated Amount
FOR a IN Cur_Alloc LOOP FOR a IN Cur_Alloc LOOP
v_Temp := a.Amount + a.DisCountAmt + a.WriteOffAmt; v_Temp := a.Amount + a.DisCountAmt + a.WriteOffAmt;
@ -104,12 +113,13 @@ BEGIN
-- DBMS_OUTPUT.PUT_LINE('== Total=' || v_TotalOpenAmt); -- DBMS_OUTPUT.PUT_LINE('== Total=' || v_TotalOpenAmt);
-- Ignore Rounding -- Ignore Rounding
IF (v_TotalOpenAmt BETWEEN -0.00999 AND 0.00999) THEN IF (v_TotalOpenAmt > -v_Min AND v_TotalOpenAmt < v_Min) THEN
v_TotalOpenAmt := 0; v_TotalOpenAmt := 0;
END IF; END IF;
-- Round to penny -- Round to currency precision
v_TotalOpenAmt := ROUND(COALESCE(v_TotalOpenAmt,0), 2); v_TotalOpenAmt := ROUND(COALESCE(v_TotalOpenAmt,0), v_Precision);
RETURN v_TotalOpenAmt; RETURN v_TotalOpenAmt;
END invoiceOpen; END invoiceOpen;
/ /

View File

@ -34,6 +34,8 @@ SELECT C_InvoicePaySchedule_ID, DueAmt FROM C_InvoicePaySchedule WHERE C_Invoice
************************************************************************/ ************************************************************************/
AS AS
v_Currency_ID NUMBER(10); v_Currency_ID NUMBER(10);
v_Precision NUMBER := 0;
v_Min NUMBER := 0;
v_TotalOpenAmt NUMBER := 0; v_TotalOpenAmt NUMBER := 0;
v_PaidAmt NUMBER := 0; v_PaidAmt NUMBER := 0;
v_Remaining NUMBER := 0; v_Remaining NUMBER := 0;
@ -73,6 +75,13 @@ BEGIN
END; END;
-- DBMS_OUTPUT.PUT_LINE('== C_Invoice_ID=' || p_C_Invoice_ID || ', Total=' || v_TotalOpenAmt || ', AP=' || v_MultiplierAP || ', CM=' || v_MultiplierCM); -- 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 POWER(1/10,v_Precision) INTO v_Min FROM DUAL;
-- Calculate Allocated Amount -- Calculate Allocated Amount
FOR a IN Cur_Alloc LOOP FOR a IN Cur_Alloc LOOP
v_Temp := a.Amount + a.DisCountAmt + a.WriteOffAmt; v_Temp := a.Amount + a.DisCountAmt + a.WriteOffAmt;
@ -107,12 +116,13 @@ BEGIN
-- DBMS_OUTPUT.PUT_LINE('== Total=' || v_TotalOpenAmt); -- DBMS_OUTPUT.PUT_LINE('== Total=' || v_TotalOpenAmt);
-- Ignore Rounding -- Ignore Rounding
IF (v_TotalOpenAmt BETWEEN -0.00999 AND 0.00999) THEN IF (v_TotalOpenAmt > -v_Min AND v_TotalOpenAmt < v_Min) THEN
v_TotalOpenAmt := 0; v_TotalOpenAmt := 0;
END IF; END IF;
-- Round to penny -- Round to currency precision
v_TotalOpenAmt := ROUND(COALESCE(v_TotalOpenAmt,0), 2); v_TotalOpenAmt := ROUND(COALESCE(v_TotalOpenAmt,0), v_Precision);
RETURN v_TotalOpenAmt; RETURN v_TotalOpenAmt;
END InvoiceopenToDate; END InvoiceopenToDate;
/ /

View File

@ -33,6 +33,8 @@ RETURN NUMBER
* *
************************************************************************/ ************************************************************************/
AS AS
v_Precision NUMBER := 0;
v_Min NUMBER := 0;
v_MultiplierAP NUMBER := 1; v_MultiplierAP NUMBER := 1;
v_PaymentAmt NUMBER := 0; v_PaymentAmt NUMBER := 0;
CURSOR Cur_Alloc IS CURSOR Cur_Alloc IS
@ -44,6 +46,13 @@ AS
WHERE al.C_Invoice_ID = p_C_Invoice_ID WHERE al.C_Invoice_ID = p_C_Invoice_ID
AND a.IsActive='Y'; AND a.IsActive='Y';
BEGIN BEGIN
SELECT StdPrecision
INTO v_Precision
FROM C_Currency
WHERE C_Currency_ID = p_C_Currency_ID;
SELECT POWER(1/10,v_Precision) INTO v_Min FROM DUAL;
-- Default -- Default
IF (p_MultiplierAP IS NOT NULL) THEN IF (p_MultiplierAP IS NOT NULL) THEN
v_MultiplierAP := p_MultiplierAP; v_MultiplierAP := p_MultiplierAP;
@ -54,7 +63,15 @@ BEGIN
+ currencyConvert(a.Amount + a.DisCountAmt + a.WriteOffAmt, + currencyConvert(a.Amount + a.DisCountAmt + a.WriteOffAmt,
a.C_Currency_ID, p_C_Currency_ID, a.DateTrx, null, a.AD_Client_ID, a.AD_Org_ID); a.C_Currency_ID, p_C_Currency_ID, a.DateTrx, null, a.AD_Client_ID, a.AD_Org_ID);
END LOOP; END LOOP;
--
RETURN ROUND(NVL(v_PaymentAmt,0), 2) * v_MultiplierAP; -- 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 invoicePaid; END invoicePaid;
/ /

View File

@ -34,6 +34,8 @@ RETURN NUMBER
* *
************************************************************************/ ************************************************************************/
AS AS
v_Precision NUMBER := 0;
v_Min NUMBER := 0;
v_MultiplierAP NUMBER := 1; v_MultiplierAP NUMBER := 1;
v_PaymentAmt NUMBER := 0; v_PaymentAmt NUMBER := 0;
CURSOR Cur_Alloc IS CURSOR Cur_Alloc IS
@ -46,6 +48,13 @@ AS
AND a.IsActive='Y' AND a.IsActive='Y'
AND a.DateAcct <= p_DateAcct; AND a.DateAcct <= p_DateAcct;
BEGIN BEGIN
SELECT StdPrecision
INTO v_Precision
FROM C_Currency
WHERE C_Currency_ID = p_C_Currency_ID;
SELECT POWER(1/10,v_Precision) INTO v_Min FROM DUAL;
-- Default -- Default
IF (p_MultiplierAP IS NOT NULL) THEN IF (p_MultiplierAP IS NOT NULL) THEN
v_MultiplierAP := p_MultiplierAP; v_MultiplierAP := p_MultiplierAP;
@ -56,7 +65,15 @@ BEGIN
+ Currencyconvert(a.Amount + a.DisCountAmt + a.WriteOffAmt, + Currencyconvert(a.Amount + a.DisCountAmt + a.WriteOffAmt,
a.C_Currency_ID, p_C_Currency_ID, a.DateTrx, NULL, a.AD_Client_ID, a.AD_Org_ID); a.C_Currency_ID, p_C_Currency_ID, a.DateTrx, NULL, a.AD_Client_ID, a.AD_Org_ID);
END LOOP; END LOOP;
--
RETURN ROUND(NVL(v_PaymentAmt,0), 2) * v_MultiplierAP; -- 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 InvoicepaidToDate; END InvoicepaidToDate;
/ /

View File

@ -24,6 +24,8 @@ RETURN NUMBER
************************************************************************/ ************************************************************************/
AS AS
v_Precision NUMBER := 0;
v_Min NUMBER := 0;
Discount NUMBER := 0; Discount NUMBER := 0;
CURSOR Cur_PT IS CURSOR Cur_PT IS
SELECT * SELECT *
@ -34,6 +36,13 @@ AS
Add1Date NUMBER := 0; Add1Date NUMBER := 0;
Add2Date NUMBER := 0; Add2Date NUMBER := 0;
BEGIN BEGIN
SELECT StdPrecision
INTO v_Precision
FROM C_Currency
WHERE C_Currency_ID = Currency_ID;
SELECT POWER(1/10,v_Precision) INTO v_Min FROM DUAL;
-- No Data - No Discount -- No Data - No Discount
IF (Amount IS NULL OR PaymentTerm_ID IS NULL OR DocDate IS NULL) THEN IF (Amount IS NULL OR PaymentTerm_ID IS NULL OR DocDate IS NULL) THEN
RETURN 0; RETURN 0;
@ -60,7 +69,15 @@ BEGIN
Discount := Amount * p.Discount2 / 100; Discount := Amount * p.Discount2 / 100;
END IF; END IF;
END LOOP; END LOOP;
--
RETURN ROUND(NVL(Discount,0), 2); -- fixed rounding -- 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 paymentTermDiscount; END paymentTermDiscount;
/ /

View File

@ -26,6 +26,8 @@ RETURN NUMBER
************************************************************************/ ************************************************************************/
AS AS
v_Precision NUMBER := 0;
v_Min NUMBER := 0;
v_AllocatedAmt NUMBER := 0; v_AllocatedAmt NUMBER := 0;
v_PayAmt NUMBER; v_PayAmt NUMBER;
CURSOR Cur_Alloc IS CURSOR Cur_Alloc IS
@ -36,6 +38,13 @@ AS
AND a.IsActive='Y'; AND a.IsActive='Y';
-- AND al.C_Invoice_ID IS NOT NULL; -- AND al.C_Invoice_ID IS NOT NULL;
BEGIN BEGIN
SELECT StdPrecision
INTO v_Precision
FROM C_Currency
WHERE C_Currency_ID = p_C_Currency_ID;
SELECT POWER(1/10,v_Precision) INTO v_Min FROM DUAL;
-- Charge - nothing available -- Charge - nothing available
SELECT MAX(PayAmt) SELECT MAX(PayAmt)
INTO v_PayAmt INTO v_PayAmt
@ -50,8 +59,15 @@ BEGIN
v_AllocatedAmt := v_AllocatedAmt v_AllocatedAmt := v_AllocatedAmt
+ currencyConvert(a.Amount, a.C_Currency_ID, p_C_Currency_ID, a.DateTrx, null, a.AD_Client_ID, a.AD_Org_ID); + currencyConvert(a.Amount, a.C_Currency_ID, p_C_Currency_ID, a.DateTrx, null, a.AD_Client_ID, a.AD_Org_ID);
END LOOP; END LOOP;
-- Round to penny
v_AllocatedAmt := ROUND(NVL(v_AllocatedAmt,0), 2); -- 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; RETURN v_AllocatedAmt;
END paymentAllocated; END paymentAllocated;
/ /

View File

@ -18,6 +18,8 @@ RETURN NUMBER
************************************************************************/ ************************************************************************/
AS AS
v_Currency_ID NUMBER(10); v_Currency_ID NUMBER(10);
v_Precision NUMBER := 0;
v_Min NUMBER := 0;
v_AvailableAmt NUMBER := 0; v_AvailableAmt NUMBER := 0;
v_IsReceipt C_Payment.IsReceipt%TYPE; v_IsReceipt C_Payment.IsReceipt%TYPE;
v_Amt NUMBER := 0; v_Amt NUMBER := 0;
@ -45,18 +47,28 @@ BEGIN
WHERE C_Payment_ID = p_C_Payment_ID; 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); -- 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 POWER(1/10,v_Precision) INTO v_Min FROM DUAL;
-- Calculate Allocated Amount -- Calculate Allocated Amount
FOR a IN Cur_Alloc LOOP FOR a IN Cur_Alloc LOOP
v_Amt := currencyConvert(a.Amount, a.C_Currency_ID, v_Currency_ID, a.DateTrx, null, a.AD_Client_ID, a.AD_Org_ID); v_Amt := currencyConvert(a.Amount, a.C_Currency_ID, v_Currency_ID, a.DateTrx, null, a.AD_Client_ID, a.AD_Org_ID);
v_AvailableAmt := v_AvailableAmt - v_Amt; v_AvailableAmt := v_AvailableAmt - v_Amt;
-- DBMS_OUTPUT.PUT_LINE(' Allocation=' || a.Amount || ' - Available=' || v_AvailableAmt); -- DBMS_OUTPUT.PUT_LINE(' Allocation=' || a.Amount || ' - Available=' || v_AvailableAmt);
END LOOP; END LOOP;
-- Ignore Rounding -- Ignore Rounding
IF (v_AvailableAmt BETWEEN -0.00999 AND 0.00999) THEN IF (v_AvailableAmt > -v_Min AND v_AvailableAmt < v_Min) THEN
v_AvailableAmt := 0; v_AvailableAmt := 0;
END IF; END IF;
-- Round to penny
v_AvailableAmt := ROUND(NVL(v_AvailableAmt,0), 2); -- Round to currency precision
v_AvailableAmt := ROUND(COALESCE(v_AvailableAmt,0), v_Precision);
RETURN v_AvailableAmt; RETURN v_AvailableAmt;
END paymentAvailable; END paymentAvailable;
/ /

View File

@ -11,11 +11,11 @@ SELECT il.AD_Client_ID, il.AD_Org_ID,
i.C_BPartner_ID, il.M_Product_ID, i.C_BPartner_ID, il.M_Product_ID,
i.DocumentNo, i.DateInvoiced, i.DateAcct, i.DocumentNo, i.DateInvoiced, i.DateAcct,
i.IsSOTrx, i.DocStatus, i.IsSOTrx, i.DocStatus,
ROUND(i.Multiplier*LineNetAmt, 2) AS LineNetAmt, currencyRound(i.Multiplier*LineNetAmt,i.C_Currency_ID,'N') AS LineNetAmt,
ROUND(i.Multiplier*PriceList*QtyInvoiced, 2) AS LineListAmt, currencyRound(i.Multiplier*PriceList*QtyInvoiced,i.C_Currency_ID,'N') AS LineListAmt,
CASE WHEN COALESCE(il.PriceLimit, 0)=0 THEN ROUND(i.Multiplier*LineNetAmt,2) ELSE ROUND(i.Multiplier*PriceLimit*QtyInvoiced,2) END AS LineLimitAmt, CASE WHEN COALESCE(il.PriceLimit, 0)=0 THEN currencyRound(i.Multiplier*LineNetAmt,i.C_Currency_ID,'N') ELSE currencyRound(i.Multiplier*il.PriceLimit*il.QtyInvoiced,i.C_Currency_ID,'N') END AS LineLimitAmt,
ROUND(i.Multiplier*PriceList*QtyInvoiced-LineNetAmt,2) AS LineDiscountAmt, currencyRound(i.Multiplier*il.PriceList*il.QtyInvoiced-il.LineNetAmt,i.C_Currency_ID,'N') AS LineDiscountAmt,
CASE WHEN COALESCE(il.PriceLimit,0)=0 THEN 0 ELSE ROUND(i.Multiplier*LineNetAmt-PriceLimit*QtyInvoiced,2) END AS LineOverLimitAmt, CASE WHEN COALESCE(il.PriceLimit,0)=0 THEN 0 ELSE currencyRound(i.Multiplier*il.LineNetAmt-il.PriceLimit*il.QtyInvoiced,i.C_Currency_ID,'N') END AS LineOverLimitAmt,
il.QtyInvoiced, il.QtyEntered, il.QtyInvoiced, il.QtyEntered,
il.Line, il.C_OrderLine_ID, il.C_UOM_ID, il.Line, il.C_OrderLine_ID, il.C_UOM_ID,
il.C_Campaign_ID, il.C_Project_ID, il.C_Activity_ID, il.C_ProjectPhase_ID, il.C_ProjectTask_ID il.C_Campaign_ID, il.C_Project_ID, il.C_Activity_ID, il.C_ProjectPhase_ID, il.C_ProjectTask_ID

View File

@ -13,7 +13,7 @@ SELECT s.ad_client_id,
sum(ms.qtyonhand - ms.qtyreserved) AS qtyavailable, sum(ms.qtyonhand - ms.qtyreserved) AS qtyavailable,
sum(ms.qtyonhand) AS qtyonhand, sum(ms.qtyonhand) AS qtyonhand,
sum(ms.qtyreserved) AS qtyreserved, sum(ms.qtyreserved) AS qtyreserved,
ROUND(MAX(mpr.pricestd),0) AS pricestd, currencyRound(MAX(mpr.pricestd),mpl.C_Currency_ID,'N') AS pricestd,
mpr.m_pricelist_version_id, mpr.m_pricelist_version_id,
mw.m_warehouse_id, mw.m_warehouse_id,
org.name AS orgname org.name AS orgname
@ -23,6 +23,8 @@ SELECT s.ad_client_id,
JOIN m_locator ml ON ms.m_locator_id = ml.m_locator_id JOIN m_locator ml ON ms.m_locator_id = ml.m_locator_id
JOIN m_warehouse mw ON ml.m_warehouse_id = mw.m_warehouse_id JOIN m_warehouse mw ON ml.m_warehouse_id = mw.m_warehouse_id
JOIN m_productprice mpr ON ms.m_product_id = mpr.m_product_id JOIN m_productprice mpr ON ms.m_product_id = mpr.m_product_id
JOIN m_pricelist_version mplv ON mplv.m_pricelist_version_id = mpr.m_pricelist_version_id
JOIN m_pricelist mpl ON mplv.m_pricelist_id = mpl.m_pricelist_id
JOIN ad_org org ON org.ad_org_id = mw.ad_org_id JOIN ad_org org ON org.ad_org_id = mw.ad_org_id
GROUP BY s.ad_client_id, GROUP BY s.ad_client_id,
s.ad_org_id, s.ad_org_id,
@ -36,7 +38,8 @@ SELECT s.ad_client_id,
mw.m_warehouse_id, mw.m_warehouse_id,
mpr.m_pricelist_version_id, mpr.m_pricelist_version_id,
org.name, org.name,
mp.name mp.name,
mpl.C_Currency_ID
UNION UNION
SELECT r.ad_client_id, SELECT r.ad_client_id,
r.ad_org_id, r.ad_org_id,
@ -52,7 +55,7 @@ SELECT s.ad_client_id,
sum(ms.qtyonhand - ms.qtyreserved) AS qtyavailable, sum(ms.qtyonhand - ms.qtyreserved) AS qtyavailable,
sum(ms.qtyonhand) AS qtyonhand, sum(ms.qtyonhand) AS qtyonhand,
sum(ms.qtyreserved) AS qtyreserved, sum(ms.qtyreserved) AS qtyreserved,
ROUND(MAX(mpr.pricestd),0) AS pricestd, currencyRound(MAX(mpr.pricestd),mpl.C_Currency_ID,'N') AS pricestd,
mpr.m_pricelist_version_id, mpr.m_pricelist_version_id,
mw.m_warehouse_id, mw.m_warehouse_id,
org.name AS orgname org.name AS orgname
@ -62,6 +65,8 @@ SELECT s.ad_client_id,
JOIN m_locator ml ON ms.m_locator_id = ml.m_locator_id JOIN m_locator ml ON ms.m_locator_id = ml.m_locator_id
JOIN m_warehouse mw ON ml.m_warehouse_id = mw.m_warehouse_id JOIN m_warehouse mw ON ml.m_warehouse_id = mw.m_warehouse_id
JOIN m_productprice mpr ON ms.m_product_id = mpr.m_product_id JOIN m_productprice mpr ON ms.m_product_id = mpr.m_product_id
JOIN m_pricelist_version mplv ON mplv.m_pricelist_version_id = mpr.m_pricelist_version_id
JOIN m_pricelist mpl ON mplv.m_pricelist_id = mpl.m_pricelist_id
JOIN ad_org org ON org.ad_org_id = mw.ad_org_id JOIN ad_org org ON org.ad_org_id = mw.ad_org_id
GROUP BY r.ad_client_id, GROUP BY r.ad_client_id,
r.ad_org_id, r.ad_org_id,
@ -75,4 +80,5 @@ SELECT s.ad_client_id,
mw.m_warehouse_id, mw.m_warehouse_id,
mpr.m_pricelist_version_id, mpr.m_pricelist_version_id,
org.name, org.name,
mp.name; mp.name,
mpl.C_Currency_ID;

View File

@ -1,6 +1,5 @@
CREATE OR REPLACE VIEW rv_c_invoiceline CREATE OR REPLACE VIEW rv_c_invoiceline AS
AS SELECT il.ad_client_id,
SELECT il.ad_client_id,
il.ad_org_id, il.ad_org_id,
il.isactive, il.isactive,
il.created, il.created,
@ -38,29 +37,16 @@ AS
il.priceactual, il.priceactual,
il.pricelimit, il.pricelimit,
il.priceentered, il.priceentered,
CASE CASE WHEN il.pricelist = 0 THEN 0 ELSE currencyRound((il.pricelist - il.priceactual) / il.pricelist * 100,i.C_Currency_ID,'N') END AS discount,
WHEN il.pricelist = 0 THEN 0 CASE WHEN il.pricelimit = 0 THEN 0 ELSE currencyRound((il.priceactual - il.pricelimit) / il.pricelimit * 100,i.C_Currency_ID,'N') END AS margin,
ELSE round(( il.pricelist - il.priceactual ) / il.pricelist * 100, 2) CASE WHEN il.pricelimit = 0 THEN 0 ELSE (il.priceactual - il.pricelimit) * il.qtyinvoiced END AS marginamt,
END AS discount, currencyRound(i.multiplier * il.linenetamt,i.C_Currency_ID,'N') AS linenetamt,
CASE currencyRound(i.multiplier * il.pricelist * il.qtyinvoiced,i.C_Currency_ID,'N') AS linelistamt,
WHEN il.pricelimit = 0 THEN 0 CASE WHEN COALESCE(il.pricelimit, 0) = 0 THEN currencyRound(i.multiplier * il.linenetamt,i.C_Currency_ID,'N') ELSE currencyRound(i.multiplier * il.pricelimit * il.qtyinvoiced,i.C_Currency_ID,'N') END
ELSE round(( il.priceactual - il.pricelimit ) / il.pricelimit * 100, 2) AS linelimitamt,
END AS margin, currencyRound(i.multiplier * il.pricelist * il.qtyinvoiced - il.linenetamt,i.C_Currency_ID,'N') AS linediscountamt,
CASE CASE WHEN COALESCE(il.pricelimit, 0) = 0 THEN 0 ELSE currencyRound(i.multiplier * il.linenetamt - il.pricelimit * il.qtyinvoiced,i.C_Currency_ID,'N') END AS
WHEN il.pricelimit = 0 THEN 0 lineoverlimitamt,
ELSE ( il.priceactual - il.pricelimit ) * il.qtyinvoiced
END AS marginamt,
round(i.multiplier * il.linenetamt, 2) AS linenetamt,
round(i.multiplier * il.pricelist * il.qtyinvoiced, 2) AS linelistamt,
CASE
WHEN COALESCE(il.pricelimit, 0) = 0 THEN round(i.multiplier * il.linenetamt, 2)
ELSE round(i.multiplier * il.pricelimit * il.qtyinvoiced, 2)
END AS linelimitamt,
round(i.multiplier * il.pricelist * il.qtyinvoiced - il.linenetamt, 2) AS linediscountamt,
CASE
WHEN COALESCE(il.pricelimit, 0) = 0 THEN 0
ELSE round(i.multiplier * il.linenetamt - il.pricelimit * il.qtyinvoiced, 2)
END AS lineoverlimitamt,
il.ad_orgtrx_id, il.ad_orgtrx_id,
il.a_processed, il.a_processed,
il.c_charge_id, il.c_charge_id,
@ -145,7 +131,7 @@ AS
pasi.serno AS m_attributesetinstance_serno, pasi.serno AS m_attributesetinstance_serno,
pasi.updated AS m_attributesetinstance_updated, pasi.updated AS m_attributesetinstance_updated,
pasi.updatedby AS m_asi_updatedby pasi.updatedby AS m_asi_updatedby
FROM rv_c_invoice i FROM rv_c_invoice i
JOIN c_invoiceline il JOIN c_invoiceline il
ON i.c_invoice_id = il.c_invoice_id ON i.c_invoice_id = il.c_invoice_id
LEFT JOIN m_product p LEFT JOIN m_product p
@ -153,4 +139,3 @@ AS
LEFT JOIN m_attributesetinstance pasi LEFT JOIN m_attributesetinstance pasi
ON il.m_attributesetinstance_id = pasi.m_attributesetinstance_id ON il.m_attributesetinstance_id = pasi.m_attributesetinstance_id
; ;

View File

@ -11,14 +11,15 @@ SELECT il.AD_Client_ID, il.AD_Org_ID,
SUM(LineLimitAmt) AS LineLimitAmt, SUM(LineLimitAmt) AS LineLimitAmt,
SUM(LineDiscountAmt) AS LineDiscountAmt, SUM(LineDiscountAmt) AS LineDiscountAmt,
CASE WHEN SUM(LineListAmt)=0 THEN 0 ELSE CASE WHEN SUM(LineListAmt)=0 THEN 0 ELSE
ROUND((SUM(LineListAmt)-SUM(LineNetAmt))/SUM(LineListAmt)*100,2) END AS LineDiscount, currencyRound((SUM(LineListAmt)-SUM(LineNetAmt))/SUM(LineListAmt)*100,i.C_Currency_ID,'N') END AS LineDiscount,
SUM(LineOverLimitAmt) AS LineOverLimitAmt, SUM(LineOverLimitAmt) AS LineOverLimitAmt,
CASE WHEN SUM(LineNetAmt)=0 THEN 0 ELSE CASE WHEN SUM(LineNetAmt)=0 THEN 0 ELSE
100-ROUND((SUM(LineNetAmt)-SUM(LineOverLimitAmt))/SUM(LineNetAmt)*100,2) END AS LineOverLimit, 100-currencyRound((SUM(LineNetAmt)-SUM(LineOverLimitAmt))/SUM(LineNetAmt)*100,i.C_Currency_ID,'N') END AS LineOverLimit,
SUM(QtyInvoiced) AS QtyInvoiced, IsSOTrx SUM(QtyInvoiced) AS QtyInvoiced, il.IsSOTrx
FROM RV_C_InvoiceLine il FROM RV_C_InvoiceLine il
INNER JOIN C_Invoice i ON (i.C_Invoice_ID=il.C_Invoice_ID)
GROUP BY il.AD_Client_ID, il.AD_Org_ID, il.C_BPartner_ID, il.M_Product_Category_ID, GROUP BY il.AD_Client_ID, il.AD_Org_ID, il.C_BPartner_ID, il.M_Product_Category_ID,
firstOf(il.DateInvoiced, 'Q'), IsSOTrx; firstOf(il.DateInvoiced, 'Q'), il.IsSOTrx, i.C_Currency_ID;

View File

@ -11,16 +11,17 @@ SELECT il.AD_Client_ID, il.AD_Org_ID,
SUM(LineLimitAmt) AS LineLimitAmt, SUM(LineLimitAmt) AS LineLimitAmt,
SUM(LineDiscountAmt) AS LineDiscountAmt, SUM(LineDiscountAmt) AS LineDiscountAmt,
CASE WHEN SUM(LineListAmt)=0 THEN 0 ELSE CASE WHEN SUM(LineListAmt)=0 THEN 0 ELSE
ROUND((SUM(LineListAmt)-SUM(LineNetAmt))/SUM(LineListAmt)*100,2) END AS LineDiscount, currencyRound((SUM(LineListAmt)-SUM(LineNetAmt))/SUM(LineListAmt)*100,i.C_Currency_ID,'N') END AS LineDiscount,
SUM(LineOverLimitAmt) AS LineOverLimitAmt, SUM(LineOverLimitAmt) AS LineOverLimitAmt,
CASE WHEN SUM(LineNetAmt)=0 THEN 0 ELSE CASE WHEN SUM(LineNetAmt)=0 THEN 0 ELSE
100-ROUND((SUM(LineNetAmt)-SUM(LineOverLimitAmt))/SUM(LineNetAmt)*100,2) END AS LineOverLimit, 100-currencyRound((SUM(LineNetAmt)-SUM(LineOverLimitAmt))/SUM(LineNetAmt)*100,i.C_Currency_ID,'N') END AS LineOverLimit,
SUM(QtyInvoiced) AS QtyInvoiced SUM(QtyInvoiced) AS QtyInvoiced
FROM RV_C_InvoiceLine il FROM RV_C_InvoiceLine il
INNER JOIN C_Invoice i ON (i.C_Invoice_ID=il.C_Invoice_ID)
INNER JOIN M_Product_PO po ON (il.M_Product_ID=po.M_Product_ID) INNER JOIN M_Product_PO po ON (il.M_Product_ID=po.M_Product_ID)
WHERE il.IsSOTrx='Y' WHERE il.IsSOTrx='Y'
GROUP BY il.AD_Client_ID, il.AD_Org_ID, il.C_BPartner_ID, po.C_BPartner_ID, GROUP BY il.AD_Client_ID, il.AD_Org_ID, il.C_BPartner_ID, po.C_BPartner_ID,
firstOf(il.DateInvoiced, 'Q'); firstOf(il.DateInvoiced, 'Q'), i.C_Currency_ID;

View File

@ -3,21 +3,22 @@ CREATE OR REPLACE VIEW RV_C_INVOICE_DAY
LINELISTAMT, LINELIMITAMT, LINEDISCOUNTAMT, LINEDISCOUNT, LINEOVERLIMITAMT, LINELISTAMT, LINELIMITAMT, LINEDISCOUNTAMT, LINEDISCOUNT, LINEOVERLIMITAMT,
LINEOVERLIMIT, ISSOTRX) LINEOVERLIMIT, ISSOTRX)
AS AS
SELECT AD_Client_ID, AD_Org_ID, SalesRep_ID, SELECT il.AD_Client_ID, il.AD_Org_ID, il.SalesRep_ID,
firstOf(DateInvoiced, 'DD') AS DateInvoiced, -- DD Day, DY Week, MM Month firstOf(il.DateInvoiced, 'DD') AS DateInvoiced, -- DD Day, DY Week, MM Month
SUM(LineNetAmt) AS LineNetAmt, SUM(LineNetAmt) AS LineNetAmt,
SUM(LineListAmt) AS LineListAmt, SUM(LineListAmt) AS LineListAmt,
SUM(LineLimitAmt) AS LineLimitAmt, SUM(LineLimitAmt) AS LineLimitAmt,
SUM(LineDiscountAmt) AS LineDiscountAmt, SUM(LineDiscountAmt) AS LineDiscountAmt,
CASE WHEN SUM(LineListAmt)=0 THEN 0 ELSE CASE WHEN SUM(LineListAmt)=0 THEN 0 ELSE
ROUND((SUM(LineListAmt)-SUM(LineNetAmt))/SUM(LineListAmt)*100,2) END AS LineDiscount, currencyRound((SUM(LineListAmt)-SUM(LineNetAmt))/SUM(LineListAmt)*100,i.C_Currency_ID,'N') END AS LineDiscount,
SUM(LineOverLimitAmt) AS LineOverLimitAmt, SUM(LineOverLimitAmt) AS LineOverLimitAmt,
CASE WHEN SUM(LineNetAmt)=0 THEN 0 ELSE CASE WHEN SUM(LineNetAmt)=0 THEN 0 ELSE
100-ROUND((SUM(LineNetAmt)-SUM(LineOverLimitAmt))/SUM(LineNetAmt)*100,2) END AS LineOverLimit, 100-currencyRound((SUM(LineNetAmt)-SUM(LineOverLimitAmt))/SUM(LineNetAmt)*100,i.C_Currency_ID,'N') END AS LineOverLimit,
IsSOTrx il.IsSOTrx
FROM RV_C_InvoiceLine FROM RV_C_InvoiceLine il
GROUP BY AD_Client_ID, AD_Org_ID, SalesRep_ID, INNER JOIN C_Invoice i ON (i.C_Invoice_ID=il.C_Invoice_ID)
firstOf(DateInvoiced, 'DD'), IsSOTrx; GROUP BY il.AD_Client_ID, il.AD_Org_ID, il.SalesRep_ID,
firstOf(il.DateInvoiced, 'DD'), il.IsSOTrx, i.C_Currency_ID;

View File

@ -3,21 +3,22 @@ CREATE OR REPLACE VIEW RV_C_INVOICE_MONTH
LINELISTAMT, LINELIMITAMT, LINEDISCOUNTAMT, LINEDISCOUNT, LINEOVERLIMITAMT, LINELISTAMT, LINELIMITAMT, LINEDISCOUNTAMT, LINEDISCOUNT, LINEOVERLIMITAMT,
LINEOVERLIMIT, ISSOTRX) LINEOVERLIMIT, ISSOTRX)
AS AS
SELECT AD_Client_ID, AD_Org_ID, SalesRep_ID, SELECT il.AD_Client_ID, il.AD_Org_ID, il.SalesRep_ID,
firstOf(DateInvoiced, 'MM') AS DateInvoiced, -- DD Day, DY Week, MM Month firstOf(il.DateInvoiced, 'MM') AS DateInvoiced, -- DD Day, DY Week, MM Month
SUM(LineNetAmt) AS LineNetAmt, SUM(LineNetAmt) AS LineNetAmt,
SUM(LineListAmt) AS LineListAmt, SUM(LineListAmt) AS LineListAmt,
SUM(LineLimitAmt) AS LineLimitAmt, SUM(LineLimitAmt) AS LineLimitAmt,
SUM(LineDiscountAmt) AS LineDiscountAmt, SUM(LineDiscountAmt) AS LineDiscountAmt,
CASE WHEN SUM(LineListAmt)=0 THEN 0 ELSE CASE WHEN SUM(LineListAmt)=0 THEN 0 ELSE
ROUND((SUM(LineListAmt)-SUM(LineNetAmt))/SUM(LineListAmt)*100,2) END AS LineDiscount, currencyRound((SUM(LineListAmt)-SUM(LineNetAmt))/SUM(LineListAmt)*100,i.C_Currency_ID,'N') END AS LineDiscount,
SUM(LineOverLimitAmt) AS LineOverLimitAmt, SUM(LineOverLimitAmt) AS LineOverLimitAmt,
CASE WHEN SUM(LineNetAmt)=0 THEN 0 ELSE CASE WHEN SUM(LineNetAmt)=0 THEN 0 ELSE
100-ROUND((SUM(LineNetAmt)-SUM(LineOverLimitAmt))/SUM(LineNetAmt)*100,2) END AS LineOverLimit, 100-currencyRound((SUM(LineNetAmt)-SUM(LineOverLimitAmt))/SUM(LineNetAmt)*100,i.C_Currency_ID,'N') END AS LineOverLimit,
IsSOTrx il.IsSOTrx
FROM RV_C_InvoiceLine FROM RV_C_InvoiceLine il
GROUP BY AD_Client_ID, AD_Org_ID, SalesRep_ID, INNER JOIN C_Invoice i ON (i.C_Invoice_ID=il.C_Invoice_ID)
firstOf(DateInvoiced, 'MM'), IsSOTrx; GROUP BY il.AD_Client_ID, il.AD_Org_ID, il.SalesRep_ID,
firstOf(il.DateInvoiced, 'MM'), il.IsSOTrx, i.C_Currency_ID;

View File

@ -10,14 +10,15 @@ SELECT il.AD_Client_ID, il.AD_Org_ID, il.M_Product_Category_ID,
SUM(il.LineLimitAmt) AS LineLimitAmt, SUM(il.LineLimitAmt) AS LineLimitAmt,
SUM(il.LineDiscountAmt) AS LineDiscountAmt, SUM(il.LineDiscountAmt) AS LineDiscountAmt,
CASE WHEN SUM(LineListAmt)=0 THEN 0 ELSE CASE WHEN SUM(LineListAmt)=0 THEN 0 ELSE
ROUND((SUM(LineListAmt)-SUM(LineNetAmt))/SUM(LineListAmt)*100,2) END AS LineDiscount, currencyRound((SUM(LineListAmt)-SUM(LineNetAmt))/SUM(LineListAmt)*100,i.C_Currency_ID,'N') END AS LineDiscount,
SUM(LineOverLimitAmt) AS LineOverLimitAmt, SUM(LineOverLimitAmt) AS LineOverLimitAmt,
CASE WHEN SUM(LineNetAmt)=0 THEN 0 ELSE CASE WHEN SUM(LineNetAmt)=0 THEN 0 ELSE
100-ROUND((SUM(LineNetAmt)-SUM(LineOverLimitAmt))/SUM(LineNetAmt)*100,2) END AS LineOverLimit, 100-currencyRound((SUM(LineNetAmt)-SUM(LineOverLimitAmt))/SUM(LineNetAmt)*100,i.C_Currency_ID,'N') END AS LineOverLimit,
SUM(QtyInvoiced) AS QtyInvoiced, IsSOTrx SUM(QtyInvoiced) AS QtyInvoiced, il.IsSOTrx
FROM RV_C_InvoiceLine il FROM RV_C_InvoiceLine il
INNER JOIN C_Invoice i ON (i.C_Invoice_ID=il.C_Invoice_ID)
GROUP BY il.AD_Client_ID, il.AD_Org_ID, il.M_Product_Category_ID, GROUP BY il.AD_Client_ID, il.AD_Org_ID, il.M_Product_Category_ID,
firstOf(il.DateInvoiced, 'MM'), IsSOTrx; firstOf(il.DateInvoiced, 'MM'), il.IsSOTrx, i.C_Currency_ID;

View File

@ -10,14 +10,15 @@ SELECT il.AD_Client_ID, il.AD_Org_ID, il.M_Product_ID,
SUM(il.LineLimitAmt) AS LineLimitAmt, SUM(il.LineLimitAmt) AS LineLimitAmt,
SUM(il.LineDiscountAmt) AS LineDiscountAmt, SUM(il.LineDiscountAmt) AS LineDiscountAmt,
CASE WHEN SUM(LineListAmt)=0 THEN 0 ELSE CASE WHEN SUM(LineListAmt)=0 THEN 0 ELSE
ROUND((SUM(LineListAmt)-SUM(LineNetAmt))/SUM(LineListAmt)*100,2) END AS LineDiscount, currencyRound((SUM(LineListAmt)-SUM(LineNetAmt))/SUM(LineListAmt)*100,i.C_Currency_ID,'N') END AS LineDiscount,
SUM(LineOverLimitAmt) AS LineOverLimitAmt, SUM(LineOverLimitAmt) AS LineOverLimitAmt,
CASE WHEN SUM(LineNetAmt)=0 THEN 0 ELSE CASE WHEN SUM(LineNetAmt)=0 THEN 0 ELSE
100-ROUND((SUM(LineNetAmt)-SUM(LineOverLimitAmt))/SUM(LineNetAmt)*100,2) END AS LineOverLimit, 100-currencyRound((SUM(LineNetAmt)-SUM(LineOverLimitAmt))/SUM(LineNetAmt)*100,i.C_Currency_ID,'N') END AS LineOverLimit,
SUM(QtyInvoiced) AS QtyInvoiced, IsSOTrx SUM(QtyInvoiced) AS QtyInvoiced, il.IsSOTrx
FROM RV_C_InvoiceLine il FROM RV_C_InvoiceLine il
INNER JOIN C_Invoice i ON (i.C_Invoice_ID=il.C_Invoice_ID)
GROUP BY il.AD_Client_ID, il.AD_Org_ID, il.M_Product_ID, GROUP BY il.AD_Client_ID, il.AD_Org_ID, il.M_Product_ID,
firstOf(il.DateInvoiced, 'MM'), IsSOTrx; firstOf(il.DateInvoiced, 'MM'), il.IsSOTrx, i.C_Currency_ID;

View File

@ -10,14 +10,15 @@ SELECT il.AD_Client_ID, il.AD_Org_ID, il.M_Product_ID,
SUM(il.LineLimitAmt) AS LineLimitAmt, SUM(il.LineLimitAmt) AS LineLimitAmt,
SUM(il.LineDiscountAmt) AS LineDiscountAmt, SUM(il.LineDiscountAmt) AS LineDiscountAmt,
CASE WHEN SUM(LineListAmt)=0 THEN 0 ELSE CASE WHEN SUM(LineListAmt)=0 THEN 0 ELSE
ROUND((SUM(LineListAmt)-SUM(LineNetAmt))/SUM(LineListAmt)*100,2) END AS LineDiscount, currencyRound((SUM(LineListAmt)-SUM(LineNetAmt))/SUM(LineListAmt)*100,i.C_Currency_ID,'N') END AS LineDiscount,
SUM(LineOverLimitAmt) AS LineOverLimitAmt, SUM(LineOverLimitAmt) AS LineOverLimitAmt,
CASE WHEN SUM(LineNetAmt)=0 THEN 0 ELSE CASE WHEN SUM(LineNetAmt)=0 THEN 0 ELSE
100-ROUND((SUM(LineNetAmt)-SUM(LineOverLimitAmt))/SUM(LineNetAmt)*100,2) END AS LineOverLimit, 100-currencyRound((SUM(LineNetAmt)-SUM(LineOverLimitAmt))/SUM(LineNetAmt)*100,i.C_Currency_ID,'N') END AS LineOverLimit,
SUM(QtyInvoiced) AS QtyInvoiced, IsSOTrx SUM(QtyInvoiced) AS QtyInvoiced, il.IsSOTrx
FROM RV_C_InvoiceLine il FROM RV_C_InvoiceLine il
INNER JOIN C_Invoice i ON (i.C_Invoice_ID=il.C_Invoice_ID)
GROUP BY il.AD_Client_ID, il.AD_Org_ID, il.M_Product_ID, GROUP BY il.AD_Client_ID, il.AD_Org_ID, il.M_Product_ID,
firstOf(il.DateInvoiced, 'Q'), IsSOTrx; firstOf(il.DateInvoiced, 'Q'), il.IsSOTrx, i.C_Currency_ID;

View File

@ -10,14 +10,15 @@ SELECT il.AD_Client_ID, il.AD_Org_ID, il.M_Product_Category_ID,
SUM(il.LineLimitAmt) AS LineLimitAmt, SUM(il.LineLimitAmt) AS LineLimitAmt,
SUM(il.LineDiscountAmt) AS LineDiscountAmt, SUM(il.LineDiscountAmt) AS LineDiscountAmt,
CASE WHEN SUM(LineListAmt)=0 THEN 0 ELSE CASE WHEN SUM(LineListAmt)=0 THEN 0 ELSE
ROUND((SUM(LineListAmt)-SUM(LineNetAmt))/SUM(LineListAmt)*100,2) END AS LineDiscount, currencyRound((SUM(LineListAmt)-SUM(LineNetAmt))/SUM(LineListAmt)*100,i.C_Currency_ID,'N') END AS LineDiscount,
SUM(LineOverLimitAmt) AS LineOverLimitAmt, SUM(LineOverLimitAmt) AS LineOverLimitAmt,
CASE WHEN SUM(LineNetAmt)=0 THEN 0 ELSE CASE WHEN SUM(LineNetAmt)=0 THEN 0 ELSE
100-ROUND((SUM(LineNetAmt)-SUM(LineOverLimitAmt))/SUM(LineNetAmt)*100,2) END AS LineOverLimit, 100-currencyRound((SUM(LineNetAmt)-SUM(LineOverLimitAmt))/SUM(LineNetAmt)*100,i.C_Currency_ID,'N') END AS LineOverLimit,
SUM(QtyInvoiced) AS QtyInvoiced, IsSOTrx SUM(QtyInvoiced) AS QtyInvoiced, il.IsSOTrx
FROM RV_C_InvoiceLine il FROM RV_C_InvoiceLine il
INNER JOIN C_Invoice i ON (i.C_Invoice_ID=il.C_Invoice_ID)
GROUP BY il.AD_Client_ID, il.AD_Org_ID, il.M_Product_Category_ID, GROUP BY il.AD_Client_ID, il.AD_Org_ID, il.M_Product_Category_ID,
firstOf(il.DateInvoiced, 'DY'), IsSOTrx; firstOf(il.DateInvoiced, 'DY'), il.IsSOTrx, i.C_Currency_ID;

View File

@ -6,21 +6,22 @@ AS
SELECT il.AD_Client_ID, il.AD_Org_ID, SELECT il.AD_Client_ID, il.AD_Org_ID,
po.C_BPartner_ID, il.M_Product_Category_ID, po.C_BPartner_ID, il.M_Product_Category_ID,
firstOf(il.DateInvoiced, 'MM') AS DateInvoiced, -- DD Day, DY Week, MM Month firstOf(il.DateInvoiced, 'MM') AS DateInvoiced, -- DD Day, DY Week, MM Month
SUM(LineNetAmt) AS LineNetAmt, SUM(il.LineNetAmt) AS LineNetAmt,
SUM(LineListAmt) AS LineListAmt, SUM(LineListAmt) AS LineListAmt,
SUM(LineLimitAmt) AS LineLimitAmt, SUM(LineLimitAmt) AS LineLimitAmt,
SUM(LineDiscountAmt) AS LineDiscountAmt, SUM(LineDiscountAmt) AS LineDiscountAmt,
CASE WHEN SUM(LineListAmt)=0 THEN 0 ELSE CASE WHEN SUM(LineListAmt)=0 THEN 0 ELSE
ROUND((SUM(LineListAmt)-SUM(LineNetAmt))/SUM(LineListAmt)*100,2) END AS LineDiscount, currencyRound((SUM(LineListAmt)-SUM(LineNetAmt))/SUM(LineListAmt)*100,i.C_Currency_ID,'N') END AS LineDiscount,
SUM(LineOverLimitAmt) AS LineOverLimitAmt, SUM(LineOverLimitAmt) AS LineOverLimitAmt,
CASE WHEN SUM(LineNetAmt)=0 THEN 0 ELSE CASE WHEN SUM(LineNetAmt)=0 THEN 0 ELSE
100-ROUND((SUM(LineNetAmt)-SUM(LineOverLimitAmt))/SUM(LineNetAmt)*100,2) END AS LineOverLimit, 100-currencyRound((SUM(LineNetAmt)-SUM(LineOverLimitAmt))/SUM(LineNetAmt)*100,i.C_Currency_ID,'N') END AS LineOverLimit,
SUM(QtyInvoiced) AS QtyInvoiced SUM(QtyInvoiced) AS QtyInvoiced
FROM RV_C_InvoiceLine il FROM RV_C_InvoiceLine il
INNER JOIN C_Invoice i ON (i.C_Invoice_ID=il.C_Invoice_ID)
INNER JOIN M_Product_PO po ON (il.M_Product_ID=po.M_Product_ID) INNER JOIN M_Product_PO po ON (il.M_Product_ID=po.M_Product_ID)
WHERE il.IsSOTrx='Y' WHERE il.IsSOTrx='Y'
GROUP BY il.AD_Client_ID, il.AD_Org_ID, po.C_BPartner_ID, il.M_Product_Category_ID, GROUP BY il.AD_Client_ID, il.AD_Org_ID, po.C_BPartner_ID, il.M_Product_Category_ID,
firstOf(il.DateInvoiced, 'MM'); firstOf(il.DateInvoiced, 'MM'), i.C_Currency_ID;

View File

@ -3,21 +3,22 @@ CREATE OR REPLACE VIEW RV_C_INVOICE_WEEK
LINELISTAMT, LINELIMITAMT, LINEDISCOUNTAMT, LINEDISCOUNT, LINEOVERLIMITAMT, LINELISTAMT, LINELIMITAMT, LINEDISCOUNTAMT, LINEDISCOUNT, LINEOVERLIMITAMT,
LINEOVERLIMIT, ISSOTRX) LINEOVERLIMIT, ISSOTRX)
AS AS
SELECT AD_Client_ID, AD_Org_ID, SalesRep_ID, SELECT il.AD_Client_ID, il.AD_Org_ID, il.SalesRep_ID,
firstOf(DateInvoiced, 'DY') AS DateInvoiced, -- DD Day, DY Week, MM Month firstOf(il.DateInvoiced, 'DY') AS DateInvoiced, -- DD Day, DY Week, MM Month
SUM(LineNetAmt) AS LineNetAmt, SUM(LineNetAmt) AS LineNetAmt,
SUM(LineListAmt) AS LineListAmt, SUM(LineListAmt) AS LineListAmt,
SUM(LineLimitAmt) AS LineLimitAmt, SUM(LineLimitAmt) AS LineLimitAmt,
SUM(LineDiscountAmt) AS LineDiscountAmt, SUM(LineDiscountAmt) AS LineDiscountAmt,
CASE WHEN SUM(LineListAmt)=0 THEN 0 ELSE CASE WHEN SUM(LineListAmt)=0 THEN 0 ELSE
ROUND((SUM(LineListAmt)-SUM(LineNetAmt))/SUM(LineListAmt)*100,2) END AS LineDiscount, currencyRound((SUM(LineListAmt)-SUM(LineNetAmt))/SUM(LineListAmt)*100,i.C_Currency_ID,'N') END AS LineDiscount,
SUM(LineOverLimitAmt) AS LineOverLimitAmt, SUM(LineOverLimitAmt) AS LineOverLimitAmt,
CASE WHEN SUM(LineNetAmt)=0 THEN 0 ELSE CASE WHEN SUM(LineNetAmt)=0 THEN 0 ELSE
100-ROUND((SUM(LineNetAmt)-SUM(LineOverLimitAmt))/SUM(LineNetAmt)*100,2) END AS LineOverLimit, 100-currencyRound((SUM(LineNetAmt)-SUM(LineOverLimitAmt))/SUM(LineNetAmt)*100,i.C_Currency_ID,'N') END AS LineOverLimit,
IsSOTrx il.IsSOTrx
FROM RV_C_InvoiceLine FROM RV_C_InvoiceLine il
GROUP BY AD_Client_ID, AD_Org_ID, SalesRep_ID, INNER JOIN C_Invoice i ON (i.C_Invoice_ID=il.C_Invoice_ID)
firstOf(DateInvoiced, 'DY'), IsSOTrx; GROUP BY il.AD_Client_ID, il.AD_Org_ID, il.SalesRep_ID,
firstOf(il.DateInvoiced, 'DY'), il.IsSOTrx, i.C_Currency_ID;

View File

@ -1,8 +1,7 @@
DROP VIEW rv_openitem; DROP VIEW rv_openitem;
CREATE OR REPLACE VIEW rv_openitem CREATE OR REPLACE VIEW rv_openitem AS
AS SELECT i.ad_org_id,
SELECT i.ad_org_id,
i.ad_client_id, i.ad_client_id,
i.documentno, i.documentno,
i.c_invoice_id, i.c_invoice_id,
@ -15,7 +14,7 @@ AS
paymenttermduedate(i.c_paymentterm_id, i.dateinvoiced) AS duedate, paymenttermduedate(i.c_paymentterm_id, i.dateinvoiced) AS duedate,
paymenttermduedays(i.c_paymentterm_id, i.dateinvoiced, getdate()) AS daysdue, paymenttermduedays(i.c_paymentterm_id, i.dateinvoiced, getdate()) AS daysdue,
adddays(i.dateinvoiced, p.discountdays) AS discountdate, adddays(i.dateinvoiced, p.discountdays) AS discountdate,
round(i.grandtotal * p.discount / 100, 2) AS discountamt, currencyRound(i.grandtotal * p.discount / 100,i.C_Currency_ID,'N') AS discountamt,
i.grandtotal, i.grandtotal,
invoicepaid(i.c_invoice_id, i.c_currency_id, 1) AS paidamt, invoicepaid(i.c_invoice_id, i.c_currency_id, 1) AS paidamt,
invoiceopen(i.c_invoice_id, 0) AS openamt, invoiceopen(i.c_invoice_id, 0) AS openamt,
@ -71,14 +70,13 @@ AS
i.updatedby, i.updatedby,
i.user1_id, i.user1_id,
i.user2_id i.user2_id
FROM rv_c_invoice i FROM rv_c_invoice i
JOIN c_paymentterm p JOIN c_paymentterm p
ON i.c_paymentterm_id = p.c_paymentterm_id ON i.c_paymentterm_id = p.c_paymentterm_id
WHERE invoiceopen(i.c_invoice_id, 0) <> 0 WHERE invoiceopen(i.c_invoice_id, 0) <> 0 AND i.ispayschedulevalid <> 'Y' AND i.docstatus IN ('CO',
AND i.ispayschedulevalid <> 'Y' 'CL')
AND i.docstatus IN ( 'CO', 'CL' ) UNION
UNION SELECT i.ad_org_id,
SELECT i.ad_org_id,
i.ad_client_id, i.ad_client_id,
i.documentno, i.documentno,
i.c_invoice_id, i.c_invoice_id,
@ -147,12 +145,9 @@ AS
i.updatedby, i.updatedby,
i.user1_id, i.user1_id,
i.user2_id i.user2_id
FROM rv_c_invoice i FROM rv_c_invoice i
JOIN c_invoicepayschedule ips JOIN c_invoicepayschedule ips
ON i.c_invoice_id = ips.c_invoice_id ON i.c_invoice_id = ips.c_invoice_id
WHERE invoiceopen(i.c_invoice_id, ips.c_invoicepayschedule_id) <> 0 WHERE invoiceopen(i.c_invoice_id, ips.c_invoicepayschedule_id) <> 0 AND i.ispayschedulevalid = 'Y' AND i.docstatus IN ('CO',
AND i.ispayschedulevalid = 'Y' 'CL') AND ips.isvalid = 'Y'
AND i.docstatus IN ( 'CO', 'CL' )
AND ips.isvalid = 'Y'
; ;

View File

@ -14,20 +14,19 @@ SELECT i.AD_Org_ID, i.AD_Client_ID,
paymentTermDueDate(i.C_PaymentTerm_ID, i.DateInvoiced) AS DueDate, paymentTermDueDate(i.C_PaymentTerm_ID, i.DateInvoiced) AS DueDate,
paymentTermDueDays(i.C_PaymentTerm_ID, i.DateInvoiced, getdate()) AS DaysDue, paymentTermDueDays(i.C_PaymentTerm_ID, i.DateInvoiced, getdate()) AS DaysDue,
addDays(i.DateInvoiced,p.DiscountDays) AS DiscountDate, addDays(i.DateInvoiced,p.DiscountDays) AS DiscountDate,
ROUND(i.GrandTotal*p.Discount/100,2) AS DiscountAmt, currencyRound(i.GrandTotal*p.Discount/100,i.C_Currency_ID,'N') AS DiscountAmt,
i.GrandTotal, i.GrandTotal,
--invoicePaid(i.C_Invoice_ID, i.C_Currency_ID, 1) AS PaidAmt, --invoicePaid(i.C_Invoice_ID, i.C_Currency_ID, 1) AS PaidAmt,
--invoiceOpen(i.C_Invoice_ID,0) AS OpenAmt, --invoiceOpen(i.C_Invoice_ID,0) AS OpenAmt,
i.C_Currency_ID, i.C_ConversionType_ID, i.C_Currency_ID, i.C_ConversionType_ID,
i.C_PaymentTerm_ID, i.C_PaymentTerm_ID,
i.IsPayScheduleValid, cast(null as number) AS C_InvoicePaySchedule_ID, i.InvoiceCollectionType, i.IsPayScheduleValid, cast(null as numeric) AS C_InvoicePaySchedule_ID, i.InvoiceCollectionType,
i.C_Campaign_ID, i.C_Project_ID, i.C_Activity_ID i.C_Campaign_ID, i.C_Project_ID, i.C_Activity_ID
FROM RV_C_Invoice i FROM RV_C_Invoice i
INNER JOIN C_PaymentTerm p ON (i.C_PaymentTerm_ID=p.C_PaymentTerm_ID) INNER JOIN C_PaymentTerm p ON (i.C_PaymentTerm_ID=p.C_PaymentTerm_ID)
WHERE -- i.IsPaid='N' WHERE -- i.IsPaid='N'
--invoiceOpen(i.C_Invoice_ID,0) <> 0 AND --invoiceOpen(i.C_Invoice_ID,0) <> 0 AND
i.IsPayScheduleValid<>'Y' i.IsPayScheduleValid<>'Y'
AND i.DocStatus<>'DR'
AND i.DocStatus IN ('CO','CL') AND i.DocStatus IN ('CO','CL')
UNION UNION
SELECT i.AD_Org_ID, i.AD_Client_ID, SELECT i.AD_Org_ID, i.AD_Client_ID,
@ -39,8 +38,8 @@ SELECT i.AD_Org_ID, i.AD_Client_ID,
ips.DiscountDate, ips.DiscountDate,
ips.DiscountAmt, ips.DiscountAmt,
ips.DueAmt AS GrandTotal, ips.DueAmt AS GrandTotal,
-- invoicePaid(i.C_Invoice_ID, i.C_Currency_ID, 1) AS PaidAmt, --invoicePaid(i.C_Invoice_ID, i.C_Currency_ID, 1) AS PaidAmt,
-- invoiceOpen(i.C_Invoice_ID, ips.C_InvoicePaySchedule_ID) AS OpenAmt, --invoiceOpen(i.C_Invoice_ID, ips.C_InvoicePaySchedule_ID) AS OpenAmt,
i.C_Currency_ID, i.C_ConversionType_ID, i.C_Currency_ID, i.C_ConversionType_ID,
i.C_PaymentTerm_ID, i.C_PaymentTerm_ID,
i.IsPayScheduleValid, ips.C_InvoicePaySchedule_ID, i.InvoiceCollectionType, i.IsPayScheduleValid, ips.C_InvoicePaySchedule_ID, i.InvoiceCollectionType,
@ -50,7 +49,6 @@ FROM RV_C_Invoice i
WHERE -- i.IsPaid='N' WHERE -- i.IsPaid='N'
--invoiceOpen(i.C_Invoice_ID,ips.C_InvoicePaySchedule_ID) <> 0 AND --invoiceOpen(i.C_Invoice_ID,ips.C_InvoicePaySchedule_ID) <> 0 AND
i.IsPayScheduleValid='Y' i.IsPayScheduleValid='Y'
AND i.DocStatus<>'DR'
AND i.DocStatus IN ('CO','CL') AND i.DocStatus IN ('CO','CL')
AND ips.IsValid='Y'; AND ips.IsValid='Y';

View File

@ -1,8 +1,7 @@
DROP VIEW rv_orderdetail; DROP VIEW rv_orderdetail;
CREATE OR REPLACE VIEW rv_orderdetail CREATE OR REPLACE VIEW rv_orderdetail AS
AS SELECT l.ad_client_id,
SELECT l.ad_client_id,
l.ad_org_id, l.ad_org_id,
l.isactive, l.isactive,
l.created, l.created,
@ -53,21 +52,12 @@ AS
l.priceentered, l.priceentered,
l.qtyordered - l.qtydelivered AS qtytodeliver, l.qtyordered - l.qtydelivered AS qtytodeliver,
l.qtyordered - l.qtyinvoiced AS qtytoinvoice, l.qtyordered - l.qtyinvoiced AS qtytoinvoice,
( l.qtyordered - l.qtyinvoiced ) * l.priceactual AS netamttoinvoice, (l.qtyordered - l.qtyinvoiced) * l.priceactual AS netamttoinvoice,
l.qtylostsales, l.qtylostsales,
l.qtylostsales * l.priceactual AS amtlostsales, l.qtylostsales * l.priceactual AS amtlostsales,
CASE CASE WHEN l.pricelist = 0 THEN 0 ELSE currencyRound((l.pricelist - l.priceactual) / l.pricelist * 100,o.C_Currency_ID,'N') END AS discount,
WHEN l.pricelist = 0 THEN 0 CASE WHEN l.pricelimit = 0 THEN 0 ELSE currencyRound((l.priceactual - l.pricelimit) / l.pricelimit * 100,o.C_Currency_ID,'N') END AS margin,
ELSE round(( l.pricelist - l.priceactual ) / l.pricelist * 100, 2) CASE WHEN l.pricelimit = 0 THEN 0 ELSE (l.priceactual - l.pricelimit) * l.qtydelivered END AS marginamt,
END AS discount,
CASE
WHEN l.pricelimit = 0 THEN 0
ELSE round(( l.priceactual - l.pricelimit ) / l.pricelimit * 100, 2)
END AS margin,
CASE
WHEN l.pricelimit = 0 THEN 0
ELSE ( l.priceactual - l.pricelimit ) * l.qtydelivered
END AS marginamt,
o.ad_org_id AS c_order_ad_org_id, o.ad_org_id AS c_order_ad_org_id,
o.ad_orgtrx_id AS c_order_ad_orgtrx_id, o.ad_orgtrx_id AS c_order_ad_orgtrx_id,
o.amountrefunded, o.amountrefunded,
@ -169,10 +159,9 @@ AS
pasi.isactive AS m_asi_isactive, pasi.isactive AS m_asi_isactive,
pasi.updated AS m_asi_updated, pasi.updated AS m_asi_updated,
pasi.updatedby AS m_asi_updatedby pasi.updatedby AS m_asi_updatedby
FROM c_order o FROM c_order o
JOIN c_orderline l JOIN c_orderline l
ON o.c_order_id = l.c_order_id ON o.c_order_id = l.c_order_id
LEFT JOIN m_attributesetinstance pasi LEFT JOIN m_attributesetinstance pasi
ON l.m_attributesetinstance_id = pasi.m_attributesetinstance_id ON l.m_attributesetinstance_id = pasi.m_attributesetinstance_id
; ;

View File

@ -44,6 +44,8 @@ AS
$BODY$ $BODY$
DECLARE DECLARE
v_Currency_ID numeric(10); v_Currency_ID numeric(10);
v_Precision NUMERIC := 0;
v_Min NUMERIC := 0;
v_TotalOpenAmt numeric := 0; v_TotalOpenAmt numeric := 0;
v_PaidAmt numeric := 0; v_PaidAmt numeric := 0;
v_Remaining numeric := 0; v_Remaining numeric := 0;
@ -67,6 +69,13 @@ BEGIN
END; END;
-- DBMS_OUTPUT.PUT_LINE('== C_Invoice_ID=' || p_C_Invoice_ID || ', Total=' || v_TotalOpenAmt || ', AP=' || v_MultiplierAP || ', CM=' || v_MultiplierCM); -- 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 -- Calculate Allocated Amount
FOR allocationline IN FOR allocationline IN
SELECT a.AD_Client_ID, a.AD_Org_ID, SELECT a.AD_Client_ID, a.AD_Org_ID,
@ -113,12 +122,114 @@ BEGIN
-- DBMS_OUTPUT.PUT_LINE('== Total=' || v_TotalOpenAmt); -- DBMS_OUTPUT.PUT_LINE('== Total=' || v_TotalOpenAmt);
-- Ignore Rounding -- Ignore Rounding
IF (v_TotalOpenAmt BETWEEN -0.00999 AND 0.00999) THEN IF (v_TotalOpenAmt > -v_Min AND v_TotalOpenAmt < v_Min) THEN
v_TotalOpenAmt := 0; v_TotalOpenAmt := 0;
END IF; END IF;
-- Round to penny -- Round to currency precision
v_TotalOpenAmt := ROUND(COALESCE(v_TotalOpenAmt,0), 2); v_TotalOpenAmt := ROUND(COALESCE(v_TotalOpenAmt,0), v_Precision);
RETURN v_TotalOpenAmt;
END;
$BODY$
LANGUAGE 'plpgsql' ;
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; RETURN v_TotalOpenAmt;
END; END;
$BODY$ $BODY$

View File

@ -33,11 +33,20 @@ RETURNS numeric AS $body$
* *
************************************************************************/ ************************************************************************/
DECLARE DECLARE
v_Precision NUMERIC := 0;
v_Min NUMERIC := 0;
v_MultiplierAP NUMERIC := 1; v_MultiplierAP NUMERIC := 1;
v_PaymentAmt NUMERIC := 0; v_PaymentAmt NUMERIC := 0;
ar RECORD; ar RECORD;
BEGIN 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 -- Default
IF (p_MultiplierAP IS NOT NULL) THEN IF (p_MultiplierAP IS NOT NULL) THEN
v_MultiplierAP := p_MultiplierAP; v_MultiplierAP := p_MultiplierAP;
@ -56,8 +65,16 @@ BEGIN
+ currencyConvert(ar.Amount + ar.DisCountAmt + ar.WriteOffAmt, + 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); ar.C_Currency_ID, p_C_Currency_ID, ar.DateTrx, null, ar.AD_Client_ID, ar.AD_Org_ID);
END LOOP; END LOOP;
--
RETURN ROUND(COALESCE(v_PaymentAmt,0), 2) * v_MultiplierAP; -- 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; END;
$body$ LANGUAGE plpgsql; $body$ LANGUAGE plpgsql;

View File

@ -45,10 +45,19 @@ RETURNS numeric
AS AS
$BODY$ $BODY$
DECLARE DECLARE
v_Precision NUMERIC := 0;
v_Min NUMERIC := 0;
v_MultiplierAP numeric := 1; v_MultiplierAP numeric := 1;
v_PaymentAmt numeric := 0; v_PaymentAmt numeric := 0;
allocation record; allocation record;
BEGIN 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 -- Default
IF (p_MultiplierAP IS NOT NULL) THEN IF (p_MultiplierAP IS NOT NULL) THEN
v_MultiplierAP := p_MultiplierAP; v_MultiplierAP := p_MultiplierAP;
@ -64,8 +73,16 @@ BEGIN
+ Currencyconvert(allocation.Amount + allocation.DisCountAmt + allocation.WriteOffAmt, + 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); allocation.C_Currency_ID, p_C_Currency_ID, allocation.DateTrx, NULL, allocation.AD_Client_ID, allocation.AD_Org_ID);
END LOOP; END LOOP;
--
RETURN ROUND(COALESCE(v_PaymentAmt,0), 2) * v_MultiplierAP; -- 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; END;
$BODY$ $BODY$
LANGUAGE 'plpgsql' ; LANGUAGE 'plpgsql' ;

View File

@ -25,6 +25,8 @@ RETURNS NUMERIC AS $body$
************************************************************************/ ************************************************************************/
DECLARE DECLARE
v_Precision NUMERIC := 0;
v_Min NUMERIC := 0;
Discount NUMERIC := 0; Discount NUMERIC := 0;
Discount1Date timestamp with time zone; Discount1Date timestamp with time zone;
Discount2Date timestamp with time zone; Discount2Date timestamp with time zone;
@ -32,6 +34,13 @@ DECLARE
Add2Date NUMERIC := 0; Add2Date NUMERIC := 0;
p RECORD; p RECORD;
BEGIN 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 -- No Data - No Discount
IF (Amount IS NULL OR PaymentTerm_ID IS NULL OR DocDate IS NULL) THEN IF (Amount IS NULL OR PaymentTerm_ID IS NULL OR DocDate IS NULL) THEN
RETURN 0; RETURN 0;
@ -59,8 +68,16 @@ BEGIN
Discount := Amount * p.Discount2 / 100; Discount := Amount * p.Discount2 / 100;
END IF; END IF;
END LOOP; END LOOP;
--
RETURN ROUND(COALESCE(Discount,0), 2); -- fixed rounding -- 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; END;
$body$ LANGUAGE plpgsql; $body$ LANGUAGE plpgsql;

View File

@ -28,10 +28,19 @@ RETURNS NUMERIC AS $body$
************************************************************************/ ************************************************************************/
DECLARE DECLARE
v_Precision NUMERIC := 0;
v_Min NUMERIC := 0;
v_AllocatedAmt NUMERIC := 0; v_AllocatedAmt NUMERIC := 0;
v_PayAmt NUMERIC; v_PayAmt NUMERIC;
r RECORD; r RECORD;
BEGIN 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 -- Charge - nothing available
SELECT SELECT
INTO v_PayAmt MAX(PayAmt) INTO v_PayAmt MAX(PayAmt)
@ -53,8 +62,15 @@ BEGIN
v_AllocatedAmt := v_AllocatedAmt 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); + currencyConvert(r.Amount, r.C_Currency_ID, p_C_Currency_ID, r.DateTrx, null, r.AD_Client_ID, r.AD_Org_ID);
END LOOP; END LOOP;
-- Round to penny
v_AllocatedAmt := ROUND(COALESCE(v_AllocatedAmt,0), 2); -- 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; RETURN v_AllocatedAmt;
END; END;

View File

@ -19,6 +19,8 @@ RETURNS NUMERIC AS $body$
************************************************************************/ ************************************************************************/
DECLARE DECLARE
v_Currency_ID NUMERIC(10); v_Currency_ID NUMERIC(10);
v_Precision NUMERIC := 0;
v_Min NUMERIC := 0;
v_AvailableAmt NUMERIC := 0; v_AvailableAmt NUMERIC := 0;
v_IsReceipt C_Payment.IsReceipt%TYPE; v_IsReceipt C_Payment.IsReceipt%TYPE;
v_Amt NUMERIC := 0; v_Amt NUMERIC := 0;
@ -41,6 +43,13 @@ BEGIN
WHERE C_Payment_ID = p_C_Payment_ID; 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); -- 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 -- Calculate Allocated Amount
FOR r IN FOR r IN
SELECT a.AD_Client_ID, a.AD_Org_ID, al.Amount, a.C_Currency_ID, a.DateTrx SELECT a.AD_Client_ID, a.AD_Org_ID, al.Amount, a.C_Currency_ID, a.DateTrx
@ -53,12 +62,15 @@ BEGIN
v_AvailableAmt := v_AvailableAmt - v_Amt; v_AvailableAmt := v_AvailableAmt - v_Amt;
-- DBMS_OUTPUT.PUT_LINE(' Allocation=' || a.Amount || ' - Available=' || v_AvailableAmt); -- DBMS_OUTPUT.PUT_LINE(' Allocation=' || a.Amount || ' - Available=' || v_AvailableAmt);
END LOOP; END LOOP;
-- Ignore Rounding -- Ignore Rounding
IF (v_AvailableAmt BETWEEN -0.00999 AND 0.00999) THEN IF (v_AvailableAmt > -v_Min AND v_AvailableAmt < v_Min) THEN
v_AvailableAmt := 0; v_AvailableAmt := 0;
END IF; END IF;
-- Round to penny
v_AvailableAmt := ROUND(COALESCE(v_AvailableAmt,0), 2); -- Round to currency precision
v_AvailableAmt := ROUND(COALESCE(v_AvailableAmt,0), v_Precision);
RETURN v_AvailableAmt; RETURN v_AvailableAmt;
END; END;

View File

@ -11,11 +11,11 @@ SELECT il.AD_Client_ID, il.AD_Org_ID,
i.C_BPartner_ID, il.M_Product_ID, i.C_BPartner_ID, il.M_Product_ID,
i.DocumentNo, i.DateInvoiced, i.DateAcct, i.DocumentNo, i.DateInvoiced, i.DateAcct,
i.IsSOTrx, i.DocStatus, i.IsSOTrx, i.DocStatus,
ROUND(i.Multiplier*LineNetAmt, 2) AS LineNetAmt, currencyRound(i.Multiplier*LineNetAmt,i.C_Currency_ID,'N') AS LineNetAmt,
ROUND(i.Multiplier*PriceList*QtyInvoiced, 2) AS LineListAmt, currencyRound(i.Multiplier*PriceList*QtyInvoiced,i.C_Currency_ID,'N') AS LineListAmt,
CASE WHEN COALESCE(il.PriceLimit, 0)=0 THEN ROUND(i.Multiplier*LineNetAmt,2) ELSE ROUND(i.Multiplier*il.PriceLimit*il.QtyInvoiced,2) END AS LineLimitAmt, CASE WHEN COALESCE(il.PriceLimit, 0)=0 THEN currencyRound(i.Multiplier*LineNetAmt,i.C_Currency_ID,'N') ELSE currencyRound(i.Multiplier*il.PriceLimit*il.QtyInvoiced,i.C_Currency_ID,'N') END AS LineLimitAmt,
ROUND(i.Multiplier*il.PriceList*il.QtyInvoiced-il.LineNetAmt,2) AS LineDiscountAmt, currencyRound(i.Multiplier*il.PriceList*il.QtyInvoiced-il.LineNetAmt,i.C_Currency_ID,'N') AS LineDiscountAmt,
CASE WHEN COALESCE(il.PriceLimit,0)=0 THEN 0 ELSE ROUND(i.Multiplier*il.LineNetAmt-il.PriceLimit*il.QtyInvoiced,2) END AS LineOverLimitAmt, CASE WHEN COALESCE(il.PriceLimit,0)=0 THEN 0 ELSE currencyRound(i.Multiplier*il.LineNetAmt-il.PriceLimit*il.QtyInvoiced,i.C_Currency_ID,'N') END AS LineOverLimitAmt,
il.QtyInvoiced, il.QtyEntered, il.QtyInvoiced, il.QtyEntered,
il.Line, il.C_OrderLine_ID, il.C_UOM_ID, il.Line, il.C_OrderLine_ID, il.C_UOM_ID,
il.C_Campaign_ID, il.C_Project_ID, il.C_Activity_ID, il.C_ProjectPhase_ID, il.C_ProjectTask_ID il.C_Campaign_ID, il.C_Project_ID, il.C_Activity_ID, il.C_ProjectPhase_ID, il.C_ProjectTask_ID

View File

@ -13,7 +13,7 @@ SELECT s.ad_client_id,
sum(ms.qtyonhand - ms.qtyreserved) AS qtyavailable, sum(ms.qtyonhand - ms.qtyreserved) AS qtyavailable,
sum(ms.qtyonhand) AS qtyonhand, sum(ms.qtyonhand) AS qtyonhand,
sum(ms.qtyreserved) AS qtyreserved, sum(ms.qtyreserved) AS qtyreserved,
ROUND(MAX(mpr.pricestd),0) AS pricestd, currencyRound(MAX(mpr.pricestd),mpl.C_Currency_ID,'N') AS pricestd,
mpr.m_pricelist_version_id, mpr.m_pricelist_version_id,
mw.m_warehouse_id, mw.m_warehouse_id,
org.name AS orgname org.name AS orgname
@ -23,6 +23,8 @@ SELECT s.ad_client_id,
JOIN m_locator ml ON ms.m_locator_id = ml.m_locator_id JOIN m_locator ml ON ms.m_locator_id = ml.m_locator_id
JOIN m_warehouse mw ON ml.m_warehouse_id = mw.m_warehouse_id JOIN m_warehouse mw ON ml.m_warehouse_id = mw.m_warehouse_id
JOIN m_productprice mpr ON ms.m_product_id = mpr.m_product_id JOIN m_productprice mpr ON ms.m_product_id = mpr.m_product_id
JOIN m_pricelist_version mplv ON mplv.m_pricelist_version_id = mpr.m_pricelist_version_id
JOIN m_pricelist mpl ON mplv.m_pricelist_id = mpl.m_pricelist_id
JOIN ad_org org ON org.ad_org_id = mw.ad_org_id JOIN ad_org org ON org.ad_org_id = mw.ad_org_id
GROUP BY s.ad_client_id, GROUP BY s.ad_client_id,
s.ad_org_id, s.ad_org_id,
@ -36,7 +38,8 @@ SELECT s.ad_client_id,
mw.m_warehouse_id, mw.m_warehouse_id,
mpr.m_pricelist_version_id, mpr.m_pricelist_version_id,
org.name, org.name,
mp.name mp.name,
mpl.C_Currency_ID
UNION UNION
SELECT r.ad_client_id, SELECT r.ad_client_id,
r.ad_org_id, r.ad_org_id,
@ -52,7 +55,7 @@ SELECT s.ad_client_id,
sum(ms.qtyonhand - ms.qtyreserved) AS qtyavailable, sum(ms.qtyonhand - ms.qtyreserved) AS qtyavailable,
sum(ms.qtyonhand) AS qtyonhand, sum(ms.qtyonhand) AS qtyonhand,
sum(ms.qtyreserved) AS qtyreserved, sum(ms.qtyreserved) AS qtyreserved,
ROUND(MAX(mpr.pricestd),0) AS pricestd, currencyRound(MAX(mpr.pricestd),mpl.C_Currency_ID,'N') AS pricestd,
mpr.m_pricelist_version_id, mpr.m_pricelist_version_id,
mw.m_warehouse_id, mw.m_warehouse_id,
org.name AS orgname org.name AS orgname
@ -62,6 +65,8 @@ SELECT s.ad_client_id,
JOIN m_locator ml ON ms.m_locator_id = ml.m_locator_id JOIN m_locator ml ON ms.m_locator_id = ml.m_locator_id
JOIN m_warehouse mw ON ml.m_warehouse_id = mw.m_warehouse_id JOIN m_warehouse mw ON ml.m_warehouse_id = mw.m_warehouse_id
JOIN m_productprice mpr ON ms.m_product_id = mpr.m_product_id JOIN m_productprice mpr ON ms.m_product_id = mpr.m_product_id
JOIN m_pricelist_version mplv ON mplv.m_pricelist_version_id = mpr.m_pricelist_version_id
JOIN m_pricelist mpl ON mplv.m_pricelist_id = mpl.m_pricelist_id
JOIN ad_org org ON org.ad_org_id = mw.ad_org_id JOIN ad_org org ON org.ad_org_id = mw.ad_org_id
GROUP BY r.ad_client_id, GROUP BY r.ad_client_id,
r.ad_org_id, r.ad_org_id,
@ -75,4 +80,5 @@ SELECT s.ad_client_id,
mw.m_warehouse_id, mw.m_warehouse_id,
mpr.m_pricelist_version_id, mpr.m_pricelist_version_id,
org.name, org.name,
mp.name; mp.name,
mpl.C_Currency_ID;

View File

@ -37,15 +37,15 @@ SELECT il.ad_client_id,
il.priceactual, il.priceactual,
il.pricelimit, il.pricelimit,
il.priceentered, il.priceentered,
CASE WHEN il.pricelist = 0 THEN 0 ELSE round((il.pricelist - il.priceactual) / il.pricelist * 100, 2) END AS discount, CASE WHEN il.pricelist = 0 THEN 0 ELSE currencyRound((il.pricelist - il.priceactual) / il.pricelist * 100,i.C_Currency_ID,'N') END AS discount,
CASE WHEN il.pricelimit = 0 THEN 0 ELSE round((il.priceactual - il.pricelimit) / il.pricelimit * 100, 2) END AS margin, CASE WHEN il.pricelimit = 0 THEN 0 ELSE currencyRound((il.priceactual - il.pricelimit) / il.pricelimit * 100,i.C_Currency_ID,'N') END AS margin,
CASE WHEN il.pricelimit = 0 THEN 0 ELSE (il.priceactual - il.pricelimit) * il.qtyinvoiced END AS marginamt, CASE WHEN il.pricelimit = 0 THEN 0 ELSE (il.priceactual - il.pricelimit) * il.qtyinvoiced END AS marginamt,
round(i.multiplier * il.linenetamt, 2) AS linenetamt, currencyRound(i.multiplier * il.linenetamt,i.C_Currency_ID,'N') AS linenetamt,
round(i.multiplier * il.pricelist * il.qtyinvoiced, 2) AS linelistamt, currencyRound(i.multiplier * il.pricelist * il.qtyinvoiced,i.C_Currency_ID,'N') AS linelistamt,
CASE WHEN COALESCE(il.pricelimit, 0) = 0 THEN round(i.multiplier * il.linenetamt, 2) ELSE round(i.multiplier * il.pricelimit * il.qtyinvoiced, 2) END CASE WHEN COALESCE(il.pricelimit, 0) = 0 THEN currencyRound(i.multiplier * il.linenetamt,i.C_Currency_ID,'N') ELSE currencyRound(i.multiplier * il.pricelimit * il.qtyinvoiced,i.C_Currency_ID,'N') END
AS linelimitamt, AS linelimitamt,
round(i.multiplier * il.pricelist * il.qtyinvoiced - il.linenetamt, 2) AS linediscountamt, currencyRound(i.multiplier * il.pricelist * il.qtyinvoiced - il.linenetamt,i.C_Currency_ID,'N') AS linediscountamt,
CASE WHEN COALESCE(il.pricelimit, 0) = 0 THEN 0 ELSE round(i.multiplier * il.linenetamt - il.pricelimit * il.qtyinvoiced, 2) END AS CASE WHEN COALESCE(il.pricelimit, 0) = 0 THEN 0 ELSE currencyRound(i.multiplier * il.linenetamt - il.pricelimit * il.qtyinvoiced,i.C_Currency_ID,'N') END AS
lineoverlimitamt, lineoverlimitamt,
il.ad_orgtrx_id, il.ad_orgtrx_id,
il.a_processed, il.a_processed,

View File

@ -11,14 +11,15 @@ SELECT il.AD_Client_ID, il.AD_Org_ID,
SUM(LineLimitAmt) AS LineLimitAmt, SUM(LineLimitAmt) AS LineLimitAmt,
SUM(LineDiscountAmt) AS LineDiscountAmt, SUM(LineDiscountAmt) AS LineDiscountAmt,
CASE WHEN SUM(LineListAmt)=0 THEN 0 ELSE CASE WHEN SUM(LineListAmt)=0 THEN 0 ELSE
ROUND((SUM(LineListAmt)-SUM(LineNetAmt))/SUM(LineListAmt)*100,2) END AS LineDiscount, currencyRound((SUM(LineListAmt)-SUM(LineNetAmt))/SUM(LineListAmt)*100,i.C_Currency_ID,'N') END AS LineDiscount,
SUM(LineOverLimitAmt) AS LineOverLimitAmt, SUM(LineOverLimitAmt) AS LineOverLimitAmt,
CASE WHEN SUM(LineNetAmt)=0 THEN 0 ELSE CASE WHEN SUM(LineNetAmt)=0 THEN 0 ELSE
100-ROUND((SUM(LineNetAmt)-SUM(LineOverLimitAmt))/SUM(LineNetAmt)*100,2) END AS LineOverLimit, 100-currencyRound((SUM(LineNetAmt)-SUM(LineOverLimitAmt))/SUM(LineNetAmt)*100,i.C_Currency_ID,'N') END AS LineOverLimit,
SUM(QtyInvoiced) AS QtyInvoiced, IsSOTrx SUM(QtyInvoiced) AS QtyInvoiced, il.IsSOTrx
FROM RV_C_InvoiceLine il FROM RV_C_InvoiceLine il
INNER JOIN C_Invoice i ON (i.C_Invoice_ID=il.C_Invoice_ID)
GROUP BY il.AD_Client_ID, il.AD_Org_ID, il.C_BPartner_ID, il.M_Product_Category_ID, GROUP BY il.AD_Client_ID, il.AD_Org_ID, il.C_BPartner_ID, il.M_Product_Category_ID,
firstOf(il.DateInvoiced, 'Q'), IsSOTrx; firstOf(il.DateInvoiced, 'Q'), il.IsSOTrx, i.C_Currency_ID;

View File

@ -11,16 +11,17 @@ SELECT il.AD_Client_ID, il.AD_Org_ID,
SUM(LineLimitAmt) AS LineLimitAmt, SUM(LineLimitAmt) AS LineLimitAmt,
SUM(LineDiscountAmt) AS LineDiscountAmt, SUM(LineDiscountAmt) AS LineDiscountAmt,
CASE WHEN SUM(LineListAmt)=0 THEN 0 ELSE CASE WHEN SUM(LineListAmt)=0 THEN 0 ELSE
ROUND((SUM(LineListAmt)-SUM(LineNetAmt))/SUM(LineListAmt)*100,2) END AS LineDiscount, currencyRound((SUM(LineListAmt)-SUM(LineNetAmt))/SUM(LineListAmt)*100,i.C_Currency_ID,'N') END AS LineDiscount,
SUM(LineOverLimitAmt) AS LineOverLimitAmt, SUM(LineOverLimitAmt) AS LineOverLimitAmt,
CASE WHEN SUM(LineNetAmt)=0 THEN 0 ELSE CASE WHEN SUM(LineNetAmt)=0 THEN 0 ELSE
100-ROUND((SUM(LineNetAmt)-SUM(LineOverLimitAmt))/SUM(LineNetAmt)*100,2) END AS LineOverLimit, 100-currencyRound((SUM(LineNetAmt)-SUM(LineOverLimitAmt))/SUM(LineNetAmt)*100,i.C_Currency_ID,'N') END AS LineOverLimit,
SUM(QtyInvoiced) AS QtyInvoiced SUM(QtyInvoiced) AS QtyInvoiced
FROM RV_C_InvoiceLine il FROM RV_C_InvoiceLine il
INNER JOIN C_Invoice i ON (i.C_Invoice_ID=il.C_Invoice_ID)
INNER JOIN M_Product_PO po ON (il.M_Product_ID=po.M_Product_ID) INNER JOIN M_Product_PO po ON (il.M_Product_ID=po.M_Product_ID)
WHERE il.IsSOTrx='Y' WHERE il.IsSOTrx='Y'
GROUP BY il.AD_Client_ID, il.AD_Org_ID, il.C_BPartner_ID, po.C_BPartner_ID, GROUP BY il.AD_Client_ID, il.AD_Org_ID, il.C_BPartner_ID, po.C_BPartner_ID,
firstOf(il.DateInvoiced, 'Q'); firstOf(il.DateInvoiced, 'Q'), i.C_Currency_ID;

View File

@ -3,21 +3,22 @@ CREATE OR REPLACE VIEW RV_C_INVOICE_DAY
LINELISTAMT, LINELIMITAMT, LINEDISCOUNTAMT, LINEDISCOUNT, LINEOVERLIMITAMT, LINELISTAMT, LINELIMITAMT, LINEDISCOUNTAMT, LINEDISCOUNT, LINEOVERLIMITAMT,
LINEOVERLIMIT, ISSOTRX) LINEOVERLIMIT, ISSOTRX)
AS AS
SELECT AD_Client_ID, AD_Org_ID, SalesRep_ID, SELECT il.AD_Client_ID, il.AD_Org_ID, il.SalesRep_ID,
firstOf(DateInvoiced, 'DD') AS DateInvoiced, -- DD Day, DY Week, MM Month firstOf(il.DateInvoiced, 'DD') AS DateInvoiced, -- DD Day, DY Week, MM Month
SUM(LineNetAmt) AS LineNetAmt, SUM(LineNetAmt) AS LineNetAmt,
SUM(LineListAmt) AS LineListAmt, SUM(LineListAmt) AS LineListAmt,
SUM(LineLimitAmt) AS LineLimitAmt, SUM(LineLimitAmt) AS LineLimitAmt,
SUM(LineDiscountAmt) AS LineDiscountAmt, SUM(LineDiscountAmt) AS LineDiscountAmt,
CASE WHEN SUM(LineListAmt)=0 THEN 0 ELSE CASE WHEN SUM(LineListAmt)=0 THEN 0 ELSE
ROUND((SUM(LineListAmt)-SUM(LineNetAmt))/SUM(LineListAmt)*100,2) END AS LineDiscount, currencyRound((SUM(LineListAmt)-SUM(LineNetAmt))/SUM(LineListAmt)*100,i.C_Currency_ID,'N') END AS LineDiscount,
SUM(LineOverLimitAmt) AS LineOverLimitAmt, SUM(LineOverLimitAmt) AS LineOverLimitAmt,
CASE WHEN SUM(LineNetAmt)=0 THEN 0 ELSE CASE WHEN SUM(LineNetAmt)=0 THEN 0 ELSE
100-ROUND((SUM(LineNetAmt)-SUM(LineOverLimitAmt))/SUM(LineNetAmt)*100,2) END AS LineOverLimit, 100-currencyRound((SUM(LineNetAmt)-SUM(LineOverLimitAmt))/SUM(LineNetAmt)*100,i.C_Currency_ID,'N') END AS LineOverLimit,
IsSOTrx il.IsSOTrx
FROM RV_C_InvoiceLine FROM RV_C_InvoiceLine il
GROUP BY AD_Client_ID, AD_Org_ID, SalesRep_ID, INNER JOIN C_Invoice i ON (i.C_Invoice_ID=il.C_Invoice_ID)
firstOf(DateInvoiced, 'DD'), IsSOTrx; GROUP BY il.AD_Client_ID, il.AD_Org_ID, il.SalesRep_ID,
firstOf(il.DateInvoiced, 'DD'), il.IsSOTrx, i.C_Currency_ID;

View File

@ -3,21 +3,22 @@ CREATE OR REPLACE VIEW RV_C_INVOICE_MONTH
LINELISTAMT, LINELIMITAMT, LINEDISCOUNTAMT, LINEDISCOUNT, LINEOVERLIMITAMT, LINELISTAMT, LINELIMITAMT, LINEDISCOUNTAMT, LINEDISCOUNT, LINEOVERLIMITAMT,
LINEOVERLIMIT, ISSOTRX) LINEOVERLIMIT, ISSOTRX)
AS AS
SELECT AD_Client_ID, AD_Org_ID, SalesRep_ID, SELECT il.AD_Client_ID, il.AD_Org_ID, il.SalesRep_ID,
firstOf(DateInvoiced, 'MM') AS DateInvoiced, -- DD Day, DY Week, MM Month firstOf(il.DateInvoiced, 'MM') AS DateInvoiced, -- DD Day, DY Week, MM Month
SUM(LineNetAmt) AS LineNetAmt, SUM(LineNetAmt) AS LineNetAmt,
SUM(LineListAmt) AS LineListAmt, SUM(LineListAmt) AS LineListAmt,
SUM(LineLimitAmt) AS LineLimitAmt, SUM(LineLimitAmt) AS LineLimitAmt,
SUM(LineDiscountAmt) AS LineDiscountAmt, SUM(LineDiscountAmt) AS LineDiscountAmt,
CASE WHEN SUM(LineListAmt)=0 THEN 0 ELSE CASE WHEN SUM(LineListAmt)=0 THEN 0 ELSE
ROUND((SUM(LineListAmt)-SUM(LineNetAmt))/SUM(LineListAmt)*100,2) END AS LineDiscount, currencyRound((SUM(LineListAmt)-SUM(LineNetAmt))/SUM(LineListAmt)*100,i.C_Currency_ID,'N') END AS LineDiscount,
SUM(LineOverLimitAmt) AS LineOverLimitAmt, SUM(LineOverLimitAmt) AS LineOverLimitAmt,
CASE WHEN SUM(LineNetAmt)=0 THEN 0 ELSE CASE WHEN SUM(LineNetAmt)=0 THEN 0 ELSE
100-ROUND((SUM(LineNetAmt)-SUM(LineOverLimitAmt))/SUM(LineNetAmt)*100,2) END AS LineOverLimit, 100-currencyRound((SUM(LineNetAmt)-SUM(LineOverLimitAmt))/SUM(LineNetAmt)*100,i.C_Currency_ID,'N') END AS LineOverLimit,
IsSOTrx il.IsSOTrx
FROM RV_C_InvoiceLine FROM RV_C_InvoiceLine il
GROUP BY AD_Client_ID, AD_Org_ID, SalesRep_ID, INNER JOIN C_Invoice i ON (i.C_Invoice_ID=il.C_Invoice_ID)
firstOf(DateInvoiced, 'MM'), IsSOTrx; GROUP BY il.AD_Client_ID, il.AD_Org_ID, il.SalesRep_ID,
firstOf(il.DateInvoiced, 'MM'), il.IsSOTrx, i.C_Currency_ID;

View File

@ -10,14 +10,15 @@ SELECT il.AD_Client_ID, il.AD_Org_ID, il.M_Product_Category_ID,
SUM(il.LineLimitAmt) AS LineLimitAmt, SUM(il.LineLimitAmt) AS LineLimitAmt,
SUM(il.LineDiscountAmt) AS LineDiscountAmt, SUM(il.LineDiscountAmt) AS LineDiscountAmt,
CASE WHEN SUM(LineListAmt)=0 THEN 0 ELSE CASE WHEN SUM(LineListAmt)=0 THEN 0 ELSE
ROUND((SUM(LineListAmt)-SUM(LineNetAmt))/SUM(LineListAmt)*100,2) END AS LineDiscount, currencyRound((SUM(LineListAmt)-SUM(LineNetAmt))/SUM(LineListAmt)*100,i.C_Currency_ID,'N') END AS LineDiscount,
SUM(LineOverLimitAmt) AS LineOverLimitAmt, SUM(LineOverLimitAmt) AS LineOverLimitAmt,
CASE WHEN SUM(LineNetAmt)=0 THEN 0 ELSE CASE WHEN SUM(LineNetAmt)=0 THEN 0 ELSE
100-ROUND((SUM(LineNetAmt)-SUM(LineOverLimitAmt))/SUM(LineNetAmt)*100,2) END AS LineOverLimit, 100-currencyRound((SUM(LineNetAmt)-SUM(LineOverLimitAmt))/SUM(LineNetAmt)*100,i.C_Currency_ID,'N') END AS LineOverLimit,
SUM(QtyInvoiced) AS QtyInvoiced, IsSOTrx SUM(QtyInvoiced) AS QtyInvoiced, il.IsSOTrx
FROM RV_C_InvoiceLine il FROM RV_C_InvoiceLine il
INNER JOIN C_Invoice i ON (i.C_Invoice_ID=il.C_Invoice_ID)
GROUP BY il.AD_Client_ID, il.AD_Org_ID, il.M_Product_Category_ID, GROUP BY il.AD_Client_ID, il.AD_Org_ID, il.M_Product_Category_ID,
firstOf(il.DateInvoiced, 'MM'), IsSOTrx; firstOf(il.DateInvoiced, 'MM'), il.IsSOTrx, i.C_Currency_ID;

View File

@ -10,14 +10,15 @@ SELECT il.AD_Client_ID, il.AD_Org_ID, il.M_Product_ID,
SUM(il.LineLimitAmt) AS LineLimitAmt, SUM(il.LineLimitAmt) AS LineLimitAmt,
SUM(il.LineDiscountAmt) AS LineDiscountAmt, SUM(il.LineDiscountAmt) AS LineDiscountAmt,
CASE WHEN SUM(LineListAmt)=0 THEN 0 ELSE CASE WHEN SUM(LineListAmt)=0 THEN 0 ELSE
ROUND((SUM(LineListAmt)-SUM(LineNetAmt))/SUM(LineListAmt)*100,2) END AS LineDiscount, currencyRound((SUM(LineListAmt)-SUM(LineNetAmt))/SUM(LineListAmt)*100,i.C_Currency_ID,'N') END AS LineDiscount,
SUM(LineOverLimitAmt) AS LineOverLimitAmt, SUM(LineOverLimitAmt) AS LineOverLimitAmt,
CASE WHEN SUM(LineNetAmt)=0 THEN 0 ELSE CASE WHEN SUM(LineNetAmt)=0 THEN 0 ELSE
100-ROUND((SUM(LineNetAmt)-SUM(LineOverLimitAmt))/SUM(LineNetAmt)*100,2) END AS LineOverLimit, 100-currencyRound((SUM(LineNetAmt)-SUM(LineOverLimitAmt))/SUM(LineNetAmt)*100,i.C_Currency_ID,'N') END AS LineOverLimit,
SUM(QtyInvoiced) AS QtyInvoiced, IsSOTrx SUM(QtyInvoiced) AS QtyInvoiced, il.IsSOTrx
FROM RV_C_InvoiceLine il FROM RV_C_InvoiceLine il
INNER JOIN C_Invoice i ON (i.C_Invoice_ID=il.C_Invoice_ID)
GROUP BY il.AD_Client_ID, il.AD_Org_ID, il.M_Product_ID, GROUP BY il.AD_Client_ID, il.AD_Org_ID, il.M_Product_ID,
firstOf(il.DateInvoiced, 'MM'), IsSOTrx; firstOf(il.DateInvoiced, 'MM'), il.IsSOTrx, i.C_Currency_ID;

View File

@ -10,14 +10,15 @@ SELECT il.AD_Client_ID, il.AD_Org_ID, il.M_Product_ID,
SUM(il.LineLimitAmt) AS LineLimitAmt, SUM(il.LineLimitAmt) AS LineLimitAmt,
SUM(il.LineDiscountAmt) AS LineDiscountAmt, SUM(il.LineDiscountAmt) AS LineDiscountAmt,
CASE WHEN SUM(LineListAmt)=0 THEN 0 ELSE CASE WHEN SUM(LineListAmt)=0 THEN 0 ELSE
ROUND((SUM(LineListAmt)-SUM(LineNetAmt))/SUM(LineListAmt)*100,2) END AS LineDiscount, currencyRound((SUM(LineListAmt)-SUM(LineNetAmt))/SUM(LineListAmt)*100,i.C_Currency_ID,'N') END AS LineDiscount,
SUM(LineOverLimitAmt) AS LineOverLimitAmt, SUM(LineOverLimitAmt) AS LineOverLimitAmt,
CASE WHEN SUM(LineNetAmt)=0 THEN 0 ELSE CASE WHEN SUM(LineNetAmt)=0 THEN 0 ELSE
100-ROUND((SUM(LineNetAmt)-SUM(LineOverLimitAmt))/SUM(LineNetAmt)*100,2) END AS LineOverLimit, 100-currencyRound((SUM(LineNetAmt)-SUM(LineOverLimitAmt))/SUM(LineNetAmt)*100,i.C_Currency_ID,'N') END AS LineOverLimit,
SUM(QtyInvoiced) AS QtyInvoiced, IsSOTrx SUM(QtyInvoiced) AS QtyInvoiced, il.IsSOTrx
FROM RV_C_InvoiceLine il FROM RV_C_InvoiceLine il
INNER JOIN C_Invoice i ON (i.C_Invoice_ID=il.C_Invoice_ID)
GROUP BY il.AD_Client_ID, il.AD_Org_ID, il.M_Product_ID, GROUP BY il.AD_Client_ID, il.AD_Org_ID, il.M_Product_ID,
firstOf(il.DateInvoiced, 'Q'), IsSOTrx; firstOf(il.DateInvoiced, 'Q'), il.IsSOTrx, i.C_Currency_ID;

View File

@ -10,14 +10,15 @@ SELECT il.AD_Client_ID, il.AD_Org_ID, il.M_Product_Category_ID,
SUM(il.LineLimitAmt) AS LineLimitAmt, SUM(il.LineLimitAmt) AS LineLimitAmt,
SUM(il.LineDiscountAmt) AS LineDiscountAmt, SUM(il.LineDiscountAmt) AS LineDiscountAmt,
CASE WHEN SUM(LineListAmt)=0 THEN 0 ELSE CASE WHEN SUM(LineListAmt)=0 THEN 0 ELSE
ROUND((SUM(LineListAmt)-SUM(LineNetAmt))/SUM(LineListAmt)*100,2) END AS LineDiscount, currencyRound((SUM(LineListAmt)-SUM(LineNetAmt))/SUM(LineListAmt)*100,i.C_Currency_ID,'N') END AS LineDiscount,
SUM(LineOverLimitAmt) AS LineOverLimitAmt, SUM(LineOverLimitAmt) AS LineOverLimitAmt,
CASE WHEN SUM(LineNetAmt)=0 THEN 0 ELSE CASE WHEN SUM(LineNetAmt)=0 THEN 0 ELSE
100-ROUND((SUM(LineNetAmt)-SUM(LineOverLimitAmt))/SUM(LineNetAmt)*100,2) END AS LineOverLimit, 100-currencyRound((SUM(LineNetAmt)-SUM(LineOverLimitAmt))/SUM(LineNetAmt)*100,i.C_Currency_ID,'N') END AS LineOverLimit,
SUM(QtyInvoiced) AS QtyInvoiced, IsSOTrx SUM(QtyInvoiced) AS QtyInvoiced, il.IsSOTrx
FROM RV_C_InvoiceLine il FROM RV_C_InvoiceLine il
INNER JOIN C_Invoice i ON (i.C_Invoice_ID=il.C_Invoice_ID)
GROUP BY il.AD_Client_ID, il.AD_Org_ID, il.M_Product_Category_ID, GROUP BY il.AD_Client_ID, il.AD_Org_ID, il.M_Product_Category_ID,
firstOf(il.DateInvoiced, 'DY'), IsSOTrx; firstOf(il.DateInvoiced, 'DY'), il.IsSOTrx, i.C_Currency_ID;

View File

@ -6,21 +6,22 @@ AS
SELECT il.AD_Client_ID, il.AD_Org_ID, SELECT il.AD_Client_ID, il.AD_Org_ID,
po.C_BPartner_ID, il.M_Product_Category_ID, po.C_BPartner_ID, il.M_Product_Category_ID,
firstOf(il.DateInvoiced, 'MM') AS DateInvoiced, -- DD Day, DY Week, MM Month firstOf(il.DateInvoiced, 'MM') AS DateInvoiced, -- DD Day, DY Week, MM Month
SUM(LineNetAmt) AS LineNetAmt, SUM(il.LineNetAmt) AS LineNetAmt,
SUM(LineListAmt) AS LineListAmt, SUM(LineListAmt) AS LineListAmt,
SUM(LineLimitAmt) AS LineLimitAmt, SUM(LineLimitAmt) AS LineLimitAmt,
SUM(LineDiscountAmt) AS LineDiscountAmt, SUM(LineDiscountAmt) AS LineDiscountAmt,
CASE WHEN SUM(LineListAmt)=0 THEN 0 ELSE CASE WHEN SUM(LineListAmt)=0 THEN 0 ELSE
ROUND((SUM(LineListAmt)-SUM(LineNetAmt))/SUM(LineListAmt)*100,2) END AS LineDiscount, currencyRound((SUM(LineListAmt)-SUM(LineNetAmt))/SUM(LineListAmt)*100,i.C_Currency_ID,'N') END AS LineDiscount,
SUM(LineOverLimitAmt) AS LineOverLimitAmt, SUM(LineOverLimitAmt) AS LineOverLimitAmt,
CASE WHEN SUM(LineNetAmt)=0 THEN 0 ELSE CASE WHEN SUM(LineNetAmt)=0 THEN 0 ELSE
100-ROUND((SUM(LineNetAmt)-SUM(LineOverLimitAmt))/SUM(LineNetAmt)*100,2) END AS LineOverLimit, 100-currencyRound((SUM(LineNetAmt)-SUM(LineOverLimitAmt))/SUM(LineNetAmt)*100,i.C_Currency_ID,'N') END AS LineOverLimit,
SUM(QtyInvoiced) AS QtyInvoiced SUM(QtyInvoiced) AS QtyInvoiced
FROM RV_C_InvoiceLine il FROM RV_C_InvoiceLine il
INNER JOIN C_Invoice i ON (i.C_Invoice_ID=il.C_Invoice_ID)
INNER JOIN M_Product_PO po ON (il.M_Product_ID=po.M_Product_ID) INNER JOIN M_Product_PO po ON (il.M_Product_ID=po.M_Product_ID)
WHERE il.IsSOTrx='Y' WHERE il.IsSOTrx='Y'
GROUP BY il.AD_Client_ID, il.AD_Org_ID, po.C_BPartner_ID, il.M_Product_Category_ID, GROUP BY il.AD_Client_ID, il.AD_Org_ID, po.C_BPartner_ID, il.M_Product_Category_ID,
firstOf(il.DateInvoiced, 'MM'); firstOf(il.DateInvoiced, 'MM'), i.C_Currency_ID;

View File

@ -3,21 +3,22 @@ CREATE OR REPLACE VIEW RV_C_INVOICE_WEEK
LINELISTAMT, LINELIMITAMT, LINEDISCOUNTAMT, LINEDISCOUNT, LINEOVERLIMITAMT, LINELISTAMT, LINELIMITAMT, LINEDISCOUNTAMT, LINEDISCOUNT, LINEOVERLIMITAMT,
LINEOVERLIMIT, ISSOTRX) LINEOVERLIMIT, ISSOTRX)
AS AS
SELECT AD_Client_ID, AD_Org_ID, SalesRep_ID, SELECT il.AD_Client_ID, il.AD_Org_ID, il.SalesRep_ID,
firstOf(DateInvoiced, 'DY') AS DateInvoiced, -- DD Day, DY Week, MM Month firstOf(il.DateInvoiced, 'DY') AS DateInvoiced, -- DD Day, DY Week, MM Month
SUM(LineNetAmt) AS LineNetAmt, SUM(LineNetAmt) AS LineNetAmt,
SUM(LineListAmt) AS LineListAmt, SUM(LineListAmt) AS LineListAmt,
SUM(LineLimitAmt) AS LineLimitAmt, SUM(LineLimitAmt) AS LineLimitAmt,
SUM(LineDiscountAmt) AS LineDiscountAmt, SUM(LineDiscountAmt) AS LineDiscountAmt,
CASE WHEN SUM(LineListAmt)=0 THEN 0 ELSE CASE WHEN SUM(LineListAmt)=0 THEN 0 ELSE
ROUND((SUM(LineListAmt)-SUM(LineNetAmt))/SUM(LineListAmt)*100,2) END AS LineDiscount, currencyRound((SUM(LineListAmt)-SUM(LineNetAmt))/SUM(LineListAmt)*100,i.C_Currency_ID,'N') END AS LineDiscount,
SUM(LineOverLimitAmt) AS LineOverLimitAmt, SUM(LineOverLimitAmt) AS LineOverLimitAmt,
CASE WHEN SUM(LineNetAmt)=0 THEN 0 ELSE CASE WHEN SUM(LineNetAmt)=0 THEN 0 ELSE
100-ROUND((SUM(LineNetAmt)-SUM(LineOverLimitAmt))/SUM(LineNetAmt)*100,2) END AS LineOverLimit, 100-currencyRound((SUM(LineNetAmt)-SUM(LineOverLimitAmt))/SUM(LineNetAmt)*100,i.C_Currency_ID,'N') END AS LineOverLimit,
IsSOTrx il.IsSOTrx
FROM RV_C_InvoiceLine FROM RV_C_InvoiceLine il
GROUP BY AD_Client_ID, AD_Org_ID, SalesRep_ID, INNER JOIN C_Invoice i ON (i.C_Invoice_ID=il.C_Invoice_ID)
firstOf(DateInvoiced, 'DY'), IsSOTrx; GROUP BY il.AD_Client_ID, il.AD_Org_ID, il.SalesRep_ID,
firstOf(il.DateInvoiced, 'DY'), il.IsSOTrx, i.C_Currency_ID;

View File

@ -14,7 +14,7 @@ SELECT i.ad_org_id,
paymenttermduedate(i.c_paymentterm_id, i.dateinvoiced) AS duedate, paymenttermduedate(i.c_paymentterm_id, i.dateinvoiced) AS duedate,
paymenttermduedays(i.c_paymentterm_id, i.dateinvoiced, getdate()) AS daysdue, paymenttermduedays(i.c_paymentterm_id, i.dateinvoiced, getdate()) AS daysdue,
adddays(i.dateinvoiced, p.discountdays) AS discountdate, adddays(i.dateinvoiced, p.discountdays) AS discountdate,
round(i.grandtotal * p.discount / 100, 2) AS discountamt, currencyRound(i.grandtotal * p.discount / 100,i.C_Currency_ID,'N') AS discountamt,
i.grandtotal, i.grandtotal,
invoicepaid(i.c_invoice_id, i.c_currency_id, 1) AS paidamt, invoicepaid(i.c_invoice_id, i.c_currency_id, 1) AS paidamt,
invoiceopen(i.c_invoice_id, 0) AS openamt, invoiceopen(i.c_invoice_id, 0) AS openamt,

View File

@ -14,7 +14,7 @@ SELECT i.AD_Org_ID, i.AD_Client_ID,
paymentTermDueDate(i.C_PaymentTerm_ID, i.DateInvoiced) AS DueDate, paymentTermDueDate(i.C_PaymentTerm_ID, i.DateInvoiced) AS DueDate,
paymentTermDueDays(i.C_PaymentTerm_ID, i.DateInvoiced, getdate()) AS DaysDue, paymentTermDueDays(i.C_PaymentTerm_ID, i.DateInvoiced, getdate()) AS DaysDue,
addDays(i.DateInvoiced,p.DiscountDays) AS DiscountDate, addDays(i.DateInvoiced,p.DiscountDays) AS DiscountDate,
ROUND(i.GrandTotal*p.Discount/100,2) AS DiscountAmt, currencyRound(i.GrandTotal*p.Discount/100,i.C_Currency_ID,'N') AS DiscountAmt,
i.GrandTotal, i.GrandTotal,
--invoicePaid(i.C_Invoice_ID, i.C_Currency_ID, 1) AS PaidAmt, --invoicePaid(i.C_Invoice_ID, i.C_Currency_ID, 1) AS PaidAmt,
--invoiceOpen(i.C_Invoice_ID,0) AS OpenAmt, --invoiceOpen(i.C_Invoice_ID,0) AS OpenAmt,

View File

@ -55,8 +55,8 @@ SELECT l.ad_client_id,
(l.qtyordered - l.qtyinvoiced) * l.priceactual AS netamttoinvoice, (l.qtyordered - l.qtyinvoiced) * l.priceactual AS netamttoinvoice,
l.qtylostsales, l.qtylostsales,
l.qtylostsales * l.priceactual AS amtlostsales, l.qtylostsales * l.priceactual AS amtlostsales,
CASE WHEN l.pricelist = 0 THEN 0 ELSE round((l.pricelist - l.priceactual) / l.pricelist * 100, 2) END AS discount, CASE WHEN l.pricelist = 0 THEN 0 ELSE currencyRound((l.pricelist - l.priceactual) / l.pricelist * 100,o.C_Currency_ID,'N') END AS discount,
CASE WHEN l.pricelimit = 0 THEN 0 ELSE round((l.priceactual - l.pricelimit) / l.pricelimit * 100, 2) END AS margin, CASE WHEN l.pricelimit = 0 THEN 0 ELSE currencyRound((l.priceactual - l.pricelimit) / l.pricelimit * 100,o.C_Currency_ID,'N') END AS margin,
CASE WHEN l.pricelimit = 0 THEN 0 ELSE (l.priceactual - l.pricelimit) * l.qtydelivered END AS marginamt, CASE WHEN l.pricelimit = 0 THEN 0 ELSE (l.priceactual - l.pricelimit) * l.qtydelivered END AS marginamt,
o.ad_org_id AS c_order_ad_org_id, o.ad_org_id AS c_order_ad_org_id,
o.ad_orgtrx_id AS c_order_ad_orgtrx_id, o.ad_orgtrx_id AS c_order_ad_orgtrx_id,

View File

@ -0,0 +1,8 @@
SET SQLBLANKLINES ON
SET DEFINE OFF
-- Mar 13, 2014 3:37:35 AM ICT
UPDATE AD_Field SET DisplayLogic='@Processed@=Y & @M_Product_ID.IsBOM@=Y',Updated=TO_DATE('2014-03-13 03:37:35','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=200271
;
SELECT register_migration_script('201403131604_IDEMPIERE-1742.sql') FROM dual
;

View File

@ -0,0 +1,17 @@
SET SQLBLANKLINES ON
SET DEFINE OFF
-- Mar 16, 2014 1:24:36 PM ICT
-- IDEMPIERE-1619 Link on third tab pointing to field on first tab instead of second
UPDATE AD_Column SET IsUpdateable='N', DefaultValue='@1|AD_WF_Node_ID@',Updated=TO_DATE('2014-03-16 13:24:36','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=10426
;
-- Mar 16, 2014 1:25:39 PM ICT
UPDATE AD_Column SET IsUpdateable='N', DefaultValue='@1|AD_WF_Node_ID@',Updated=TO_DATE('2014-03-16 13:25:39','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=304
;
UPDATE AD_Column SET IsUpdateable='N', DefaultValue='@4|AD_WF_NodeNext_ID@',Updated=TO_DATE('2014-03-20 02:22:55','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=11571
;
SELECT register_migration_script('201403161604_IDEMPIERE-1619.sql') FROM dual
;

View File

@ -0,0 +1,19 @@
SET SQLBLANKLINES ON
SET DEFINE OFF
-- Mar 24, 2014 8:09:18 PM COT
-- IDEMPIERE-1852 Translation: Accounting Fact Reconcilation (manual)
INSERT INTO AD_Message (MsgType,MsgText,AD_Message_ID,EntityType,AD_Message_UU,Value,IsActive,Updated,CreatedBy,UpdatedBy,Created,AD_Client_ID,AD_Org_ID) VALUES ('I','DR',200260,'D','40c2b5df-fe62-4d94-9376-fa82bfe99969','DR','Y',TO_DATE('2014-03-24 20:09:17','YYYY-MM-DD HH24:MI:SS'),100,100,TO_DATE('2014-03-24 20:09:17','YYYY-MM-DD HH24:MI:SS'),0,0)
;
-- Mar 24, 2014 8:09:35 PM COT
INSERT INTO AD_Message (MsgType,MsgText,AD_Message_ID,EntityType,AD_Message_UU,Value,IsActive,Updated,CreatedBy,UpdatedBy,Created,AD_Client_ID,AD_Org_ID) VALUES ('I','CR',200261,'D','c4c434ec-7516-46c0-ad29-122c2b871b04','CR','Y',TO_DATE('2014-03-24 20:09:35','YYYY-MM-DD HH24:MI:SS'),100,100,TO_DATE('2014-03-24 20:09:35','YYYY-MM-DD HH24:MI:SS'),0,0)
;
-- Mar 24, 2014 8:10:25 PM COT
INSERT INTO AD_Message (MsgType,MsgText,AD_Message_ID,EntityType,AD_Message_UU,Value,IsActive,Updated,CreatedBy,UpdatedBy,Created,AD_Client_ID,AD_Org_ID) VALUES ('I','DR/CR',200262,'D','41ceddd4-a1d0-4387-8d64-f10391a9badf','DR/CR','Y',TO_DATE('2014-03-24 20:10:24','YYYY-MM-DD HH24:MI:SS'),100,100,TO_DATE('2014-03-24 20:10:24','YYYY-MM-DD HH24:MI:SS'),0,0)
;
SELECT register_migration_script('201403242011_IDEMPIERE-1852.sql') FROM dual
;

View File

@ -0,0 +1,5 @@
-- Mar 13, 2014 3:37:35 AM ICT
UPDATE AD_Field SET DisplayLogic='@Processed@=Y & @M_Product_ID.IsBOM@=Y',Updated=TO_TIMESTAMP('2014-03-13 03:37:35','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=200271
;
SELECT register_migration_script('201403131604_IDEMPIERE-1742.sql') FROM dual
;

View File

@ -0,0 +1,14 @@
-- Mar 16, 2014 1:24:36 PM ICT
-- IDEMPIERE-1619 Link on third tab pointing to field on first tab instead of second
UPDATE AD_Column SET IsUpdateable='N', DefaultValue='@1|AD_WF_Node_ID@',Updated=TO_TIMESTAMP('2014-03-16 13:24:36','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=10426
;
-- Mar 16, 2014 1:25:39 PM ICT
UPDATE AD_Column SET IsUpdateable='N', DefaultValue='@1|AD_WF_Node_ID@',Updated=TO_TIMESTAMP('2014-03-16 13:25:39','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=304
;
UPDATE AD_Column SET IsUpdateable='N', DefaultValue='@4|AD_WF_NodeNext_ID@',Updated=TO_TIMESTAMP('2014-03-20 02:22:55','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=11571
;
SELECT register_migration_script('201403161604_IDEMPIERE-1619.sql') FROM dual
;

View File

@ -0,0 +1,16 @@
-- Mar 24, 2014 8:09:18 PM COT
-- IDEMPIERE-1852 Translation: Accounting Fact Reconcilation (manual)
INSERT INTO AD_Message (MsgType,MsgText,AD_Message_ID,EntityType,AD_Message_UU,Value,IsActive,Updated,CreatedBy,UpdatedBy,Created,AD_Client_ID,AD_Org_ID) VALUES ('I','DR',200260,'D','40c2b5df-fe62-4d94-9376-fa82bfe99969','DR','Y',TO_TIMESTAMP('2014-03-24 20:09:17','YYYY-MM-DD HH24:MI:SS'),100,100,TO_TIMESTAMP('2014-03-24 20:09:17','YYYY-MM-DD HH24:MI:SS'),0,0)
;
-- Mar 24, 2014 8:09:35 PM COT
INSERT INTO AD_Message (MsgType,MsgText,AD_Message_ID,EntityType,AD_Message_UU,Value,IsActive,Updated,CreatedBy,UpdatedBy,Created,AD_Client_ID,AD_Org_ID) VALUES ('I','CR',200261,'D','c4c434ec-7516-46c0-ad29-122c2b871b04','CR','Y',TO_TIMESTAMP('2014-03-24 20:09:35','YYYY-MM-DD HH24:MI:SS'),100,100,TO_TIMESTAMP('2014-03-24 20:09:35','YYYY-MM-DD HH24:MI:SS'),0,0)
;
-- Mar 24, 2014 8:10:25 PM COT
INSERT INTO AD_Message (MsgType,MsgText,AD_Message_ID,EntityType,AD_Message_UU,Value,IsActive,Updated,CreatedBy,UpdatedBy,Created,AD_Client_ID,AD_Org_ID) VALUES ('I','DR/CR',200262,'D','41ceddd4-a1d0-4387-8d64-f10391a9badf','DR/CR','Y',TO_TIMESTAMP('2014-03-24 20:10:24','YYYY-MM-DD HH24:MI:SS'),100,100,TO_TIMESTAMP('2014-03-24 20:10:24','YYYY-MM-DD HH24:MI:SS'),0,0)
;
SELECT register_migration_script('201403242011_IDEMPIERE-1852.sql') FROM dual
;

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -397,10 +397,10 @@ public class ChartBuilder {
private JFreeChart createXYBarChart() { private JFreeChart createXYBarChart() {
JFreeChart chart = ChartFactory.createXYBarChart( JFreeChart chart = ChartFactory.createXYBarChart(
chartModel.getName(), // chart title chartModel.get_Translation(MChart.COLUMNNAME_Name), // chart title
chartModel.getDomainLabel(), // domain axis label chartModel.get_Translation(MChart.COLUMNNAME_DomainLabel), // domain axis label
true, true,
chartModel.getRangeLabel(), // range axis label chartModel.get_Translation(MChart.COLUMNNAME_RangeLabel), // range axis label
getXYDataset(), // data getXYDataset(), // data
X_AD_Chart.CHARTORIENTATION_Horizontal.equals(chartModel.getChartOrientation()) X_AD_Chart.CHARTORIENTATION_Horizontal.equals(chartModel.getChartOrientation())
? PlotOrientation.HORIZONTAL : PlotOrientation.VERTICAL, // orientation ? PlotOrientation.HORIZONTAL : PlotOrientation.VERTICAL, // orientation
@ -415,9 +415,9 @@ public class ChartBuilder {
private JFreeChart createTimeSeriesChart() { private JFreeChart createTimeSeriesChart() {
JFreeChart chart = ChartFactory.createTimeSeriesChart( JFreeChart chart = ChartFactory.createTimeSeriesChart(
chartModel.getName(), // chart title chartModel.get_Translation(MChart.COLUMNNAME_Name), // chart title
chartModel.getDomainLabel(), // domain axis label chartModel.get_Translation(MChart.COLUMNNAME_DomainLabel), // domain axis label
chartModel.getRangeLabel(), // range axis label chartModel.get_Translation(MChart.COLUMNNAME_RangeLabel), // range axis label
getXYDataset(), // data getXYDataset(), // data
chartModel.isDisplayLegend(), // include legend chartModel.isDisplayLegend(), // include legend
true, // tooltips? true, // tooltips?
@ -430,9 +430,9 @@ public class ChartBuilder {
private JFreeChart createWaterfallChart() { private JFreeChart createWaterfallChart() {
JFreeChart chart = ChartFactory.createWaterfallChart( JFreeChart chart = ChartFactory.createWaterfallChart(
chartModel.getName(), // chart title chartModel.get_Translation(MChart.COLUMNNAME_Name), // chart title
chartModel.getDomainLabel(), // domain axis label chartModel.get_Translation(MChart.COLUMNNAME_DomainLabel), // domain axis label
chartModel.getRangeLabel(), // range axis label chartModel.get_Translation(MChart.COLUMNNAME_RangeLabel), // range axis label
getCategoryDataset(), // data getCategoryDataset(), // data
X_AD_Chart.CHARTORIENTATION_Horizontal.equals(chartModel.getChartOrientation()) X_AD_Chart.CHARTORIENTATION_Horizontal.equals(chartModel.getChartOrientation())
? PlotOrientation.HORIZONTAL : PlotOrientation.VERTICAL, // orientation ? PlotOrientation.HORIZONTAL : PlotOrientation.VERTICAL, // orientation
@ -446,21 +446,21 @@ public class ChartBuilder {
} }
private JFreeChart createRingChart() { private JFreeChart createRingChart() {
final JFreeChart chart = ChartFactory.createRingChart(chartModel.getName(), final JFreeChart chart = ChartFactory.createRingChart(chartModel.get_Translation(MChart.COLUMNNAME_Name),
getPieDataset(), chartModel.isDisplayLegend(), true, true); getPieDataset(), chartModel.isDisplayLegend(), true, true);
return chart; return chart;
} }
private JFreeChart createPieChart() { private JFreeChart createPieChart() {
final JFreeChart chart = ChartFactory.createPieChart(chartModel.getName(), final JFreeChart chart = ChartFactory.createPieChart(chartModel.get_Translation(MChart.COLUMNNAME_Name),
getPieDataset(), false, true, true); getPieDataset(), false, true, true);
return chart; return chart;
} }
private JFreeChart create3DPieChart() { private JFreeChart create3DPieChart() {
final JFreeChart chart = ChartFactory.createPieChart3D(chartModel.getName(), final JFreeChart chart = ChartFactory.createPieChart3D(chartModel.get_Translation(MChart.COLUMNNAME_Name),
getPieDataset(), false, true, true); getPieDataset(), false, true, true);
return chart; return chart;
@ -468,9 +468,9 @@ public class ChartBuilder {
private JFreeChart createBarChart() { private JFreeChart createBarChart() {
JFreeChart chart = ChartFactory.createBarChart( JFreeChart chart = ChartFactory.createBarChart(
chartModel.getName(), // chart title chartModel.get_Translation(MChart.COLUMNNAME_Name), // chart title
chartModel.getDomainLabel(), // domain axis label chartModel.get_Translation(MChart.COLUMNNAME_DomainLabel), // domain axis label
chartModel.getRangeLabel(), // range axis label chartModel.get_Translation(MChart.COLUMNNAME_RangeLabel), // range axis label
getCategoryDataset(), // data getCategoryDataset(), // data
X_AD_Chart.CHARTORIENTATION_Horizontal.equals(chartModel.getChartOrientation()) X_AD_Chart.CHARTORIENTATION_Horizontal.equals(chartModel.getChartOrientation())
? PlotOrientation.HORIZONTAL : PlotOrientation.VERTICAL, // orientation ? PlotOrientation.HORIZONTAL : PlotOrientation.VERTICAL, // orientation
@ -491,9 +491,9 @@ public class ChartBuilder {
private JFreeChart create3DBarChart() { private JFreeChart create3DBarChart() {
JFreeChart chart = ChartFactory.createBarChart3D( JFreeChart chart = ChartFactory.createBarChart3D(
chartModel.getName(), // chart title chartModel.get_Translation(MChart.COLUMNNAME_Name), // chart title
chartModel.getDomainLabel(), // domain axis label chartModel.get_Translation(MChart.COLUMNNAME_DomainLabel), // domain axis label
chartModel.getRangeLabel(), // range axis label chartModel.get_Translation(MChart.COLUMNNAME_RangeLabel), // range axis label
getCategoryDataset(), // data getCategoryDataset(), // data
X_AD_Chart.CHARTORIENTATION_Horizontal.equals(chartModel.getChartOrientation()) X_AD_Chart.CHARTORIENTATION_Horizontal.equals(chartModel.getChartOrientation())
? PlotOrientation.HORIZONTAL : PlotOrientation.VERTICAL, // orientation ? PlotOrientation.HORIZONTAL : PlotOrientation.VERTICAL, // orientation
@ -508,9 +508,9 @@ public class ChartBuilder {
private JFreeChart createStackedBarChart() { private JFreeChart createStackedBarChart() {
JFreeChart chart = ChartFactory.createStackedBarChart( JFreeChart chart = ChartFactory.createStackedBarChart(
chartModel.getName(), // chart title chartModel.get_Translation(MChart.COLUMNNAME_Name), // chart title
chartModel.getDomainLabel(), // domain axis label chartModel.get_Translation(MChart.COLUMNNAME_DomainLabel), // domain axis label
chartModel.getRangeLabel(), // range axis label chartModel.get_Translation(MChart.COLUMNNAME_RangeLabel), // range axis label
getCategoryDataset(), // data getCategoryDataset(), // data
X_AD_Chart.CHARTORIENTATION_Horizontal.equals(chartModel.getChartOrientation()) X_AD_Chart.CHARTORIENTATION_Horizontal.equals(chartModel.getChartOrientation())
? PlotOrientation.HORIZONTAL : PlotOrientation.VERTICAL, // orientation ? PlotOrientation.HORIZONTAL : PlotOrientation.VERTICAL, // orientation
@ -532,9 +532,9 @@ public class ChartBuilder {
private JFreeChart create3DStackedBarChart() { private JFreeChart create3DStackedBarChart() {
JFreeChart chart = ChartFactory.createStackedBarChart3D( JFreeChart chart = ChartFactory.createStackedBarChart3D(
chartModel.getName(), // chart title chartModel.get_Translation(MChart.COLUMNNAME_Name), // chart title
chartModel.getDomainLabel(), // domain axis label chartModel.get_Translation(MChart.COLUMNNAME_DomainLabel), // domain axis label
chartModel.getRangeLabel(), // range axis label chartModel.get_Translation(MChart.COLUMNNAME_RangeLabel), // range axis label
getCategoryDataset(), // data getCategoryDataset(), // data
X_AD_Chart.CHARTORIENTATION_Horizontal.equals(chartModel.getChartOrientation()) X_AD_Chart.CHARTORIENTATION_Horizontal.equals(chartModel.getChartOrientation())
? PlotOrientation.HORIZONTAL : PlotOrientation.VERTICAL, // orientation ? PlotOrientation.HORIZONTAL : PlotOrientation.VERTICAL, // orientation
@ -550,9 +550,9 @@ public class ChartBuilder {
private JFreeChart createAreaChart() { private JFreeChart createAreaChart() {
// create the chart... // create the chart...
JFreeChart chart = ChartFactory.createAreaChart( JFreeChart chart = ChartFactory.createAreaChart(
chartModel.getName(), // chart title chartModel.get_Translation(MChart.COLUMNNAME_Name), // chart title
chartModel.getDomainLabel(), // domain axis label chartModel.get_Translation(MChart.COLUMNNAME_DomainLabel), // domain axis label
chartModel.getRangeLabel(), // range axis label chartModel.get_Translation(MChart.COLUMNNAME_RangeLabel), // range axis label
getCategoryDataset(), // data getCategoryDataset(), // data
X_AD_Chart.CHARTORIENTATION_Horizontal.equals(chartModel.getChartOrientation()) X_AD_Chart.CHARTORIENTATION_Horizontal.equals(chartModel.getChartOrientation())
? PlotOrientation.HORIZONTAL : PlotOrientation.VERTICAL, // orientation ? PlotOrientation.HORIZONTAL : PlotOrientation.VERTICAL, // orientation
@ -568,9 +568,9 @@ public class ChartBuilder {
private JFreeChart createStackedAreaChart() { private JFreeChart createStackedAreaChart() {
// create the chart... // create the chart...
JFreeChart chart = ChartFactory.createStackedAreaChart( JFreeChart chart = ChartFactory.createStackedAreaChart(
chartModel.getName(), // chart title chartModel.get_Translation(MChart.COLUMNNAME_Name), // chart title
chartModel.getDomainLabel(), // domain axis label chartModel.get_Translation(MChart.COLUMNNAME_DomainLabel), // domain axis label
chartModel.getRangeLabel(), // range axis label chartModel.get_Translation(MChart.COLUMNNAME_RangeLabel), // range axis label
getCategoryDataset(), // data getCategoryDataset(), // data
X_AD_Chart.CHARTORIENTATION_Horizontal.equals(chartModel.getChartOrientation()) X_AD_Chart.CHARTORIENTATION_Horizontal.equals(chartModel.getChartOrientation())
? PlotOrientation.HORIZONTAL : PlotOrientation.VERTICAL, // orientation ? PlotOrientation.HORIZONTAL : PlotOrientation.VERTICAL, // orientation
@ -586,9 +586,9 @@ public class ChartBuilder {
private JFreeChart createLineChart() { private JFreeChart createLineChart() {
// create the chart... // create the chart...
JFreeChart chart = ChartFactory.createLineChart( JFreeChart chart = ChartFactory.createLineChart(
chartModel.getName(), // chart title chartModel.get_Translation(MChart.COLUMNNAME_Name), // chart title
chartModel.getDomainLabel(), // domain axis label chartModel.get_Translation(MChart.COLUMNNAME_DomainLabel), // domain axis label
chartModel.getRangeLabel(), // range axis label chartModel.get_Translation(MChart.COLUMNNAME_RangeLabel), // range axis label
getCategoryDataset(), // data getCategoryDataset(), // data
X_AD_Chart.CHARTORIENTATION_Horizontal.equals(chartModel.getChartOrientation()) X_AD_Chart.CHARTORIENTATION_Horizontal.equals(chartModel.getChartOrientation())
? PlotOrientation.HORIZONTAL : PlotOrientation.VERTICAL, // orientation ? PlotOrientation.HORIZONTAL : PlotOrientation.VERTICAL, // orientation
@ -605,9 +605,9 @@ public class ChartBuilder {
private JFreeChart create3DLineChart() { private JFreeChart create3DLineChart() {
// create the chart... // create the chart...
JFreeChart chart = ChartFactory.createLineChart3D( JFreeChart chart = ChartFactory.createLineChart3D(
chartModel.getName(), // chart title chartModel.get_Translation(MChart.COLUMNNAME_Name), // chart title
chartModel.getDomainLabel(), // domain axis label chartModel.get_Translation(MChart.COLUMNNAME_DomainLabel), // domain axis label
chartModel.getRangeLabel(), // range axis label chartModel.get_Translation(MChart.COLUMNNAME_RangeLabel), // range axis label
getCategoryDataset(), // data getCategoryDataset(), // data
X_AD_Chart.CHARTORIENTATION_Horizontal.equals(chartModel.getChartOrientation()) X_AD_Chart.CHARTORIENTATION_Horizontal.equals(chartModel.getChartOrientation())
? PlotOrientation.HORIZONTAL : PlotOrientation.VERTICAL, // orientation ? PlotOrientation.HORIZONTAL : PlotOrientation.VERTICAL, // orientation

View File

@ -54,7 +54,7 @@ public class DefaultLookupFactory implements ILookupFactory{
} }
else if (gridFieldVO.displayType == Payment) else if (gridFieldVO.displayType == Payment)
{ {
lookup = new MPaymentLookup (gridFieldVO.ctx, gridFieldVO.WindowNo, gridFieldVO.AD_Column_ID); lookup = new MPaymentLookup (gridFieldVO.ctx, gridFieldVO.WindowNo, gridFieldVO.ValidationCode);
} }
else if (DisplayType.isLookup(gridFieldVO.displayType) && gridFieldVO.lookupInfo != null) else if (DisplayType.isLookup(gridFieldVO.displayType) && gridFieldVO.lookupInfo != null)
{ {

View File

@ -13,13 +13,18 @@
*****************************************************************************/ *****************************************************************************/
package org.adempiere.base; package org.adempiere.base;
import java.util.Map;
import org.adempiere.util.ModelClassGenerator;
import org.adempiere.util.ModelGeneratorDialog; import org.adempiere.util.ModelGeneratorDialog;
import org.adempiere.util.ModelInterfaceGenerator;
import org.compiere.Adempiere; import org.compiere.Adempiere;
import org.eclipse.equinox.app.IApplication; import org.eclipse.equinox.app.IApplication;
import org.eclipse.equinox.app.IApplicationContext; import org.eclipse.equinox.app.IApplicationContext;
/** /**
* @author hengsin * @author hengsin
* @author tbayen - command line start
* *
*/ */
public class ModelGeneratorApplication implements IApplication { public class ModelGeneratorApplication implements IApplication {
@ -30,11 +35,25 @@ public class ModelGeneratorApplication implements IApplication {
@Override @Override
public Object start(IApplicationContext context) throws Exception { public Object start(IApplicationContext context) throws Exception {
Adempiere.startup(false); Adempiere.startup(false);
Map<?, ?> args = context.getArguments();
// IDEMPIERE-1686 - GenerateModel does not take commandline arguments
String commandlineArgs[] = (String[]) args.get("application.args");
if (commandlineArgs.length == 4) {
String folder = commandlineArgs[0];
String packageName = commandlineArgs[1];
String entityType = commandlineArgs[2];
String tableName = commandlineArgs[3];
ModelInterfaceGenerator.generateSource(folder, packageName, entityType, tableName);
ModelClassGenerator.generateSource(folder, packageName, entityType, tableName);
} else if (commandlineArgs.length != 0) {
System.out.println("usage: ModelGenerator folder packageName entityType tableName");
} else {
ModelGeneratorDialog dialog = new ModelGeneratorDialog(); ModelGeneratorDialog dialog = new ModelGeneratorDialog();
dialog.setModal(true); dialog.setModal(true);
dialog.pack(); dialog.pack();
dialog.setLocationRelativeTo(null); dialog.setLocationRelativeTo(null);
dialog.setVisible(true); dialog.setVisible(true);
}
return IApplication.EXIT_OK; return IApplication.EXIT_OK;
} }

View File

@ -104,6 +104,8 @@ public class GridTabCSVExporter implements IGridTabExporter
if(DisplayType.Location == field.getDisplayType()){ if(DisplayType.Location == field.getDisplayType()){
specialHDispayType = DisplayType.Location; specialHDispayType = DisplayType.Location;
continue; continue;
} else if (! (field.isDisplayed() || field.isDisplayedGrid())) {
continue;
} }
String headName = resolveColumnName(table, column); String headName = resolveColumnName(table, column);
headArray.add(headName); headArray.add(headName);
@ -525,7 +527,10 @@ public class GridTabCSVExporter implements IGridTabExporter
int AD_Field_ID = Integer.parseInt(fieldIdStr); int AD_Field_ID = Integer.parseInt(fieldIdStr);
for (GridField gridField : tmpFields) for (GridField gridField : tmpFields)
{ {
if(gridField.isVirtualColumn() || gridField.isEncrypted() || gridField.isEncryptedColumn()) if ( gridField.isVirtualColumn()
|| gridField.isEncrypted()
|| gridField.isEncryptedColumn()
|| !(gridField.isDisplayed() || gridField.isDisplayedGrid()))
continue; continue;
if (gridField.getAD_Field_ID() == AD_Field_ID) if (gridField.getAD_Field_ID() == AD_Field_ID)
@ -549,7 +554,10 @@ public class GridTabCSVExporter implements IGridTabExporter
continue; continue;
if (DisplayType.Button == MColumn.get(Env.getCtx(),field.getAD_Column_ID()).getAD_Reference_ID()) if (DisplayType.Button == MColumn.get(Env.getCtx(),field.getAD_Column_ID()).getAD_Reference_ID())
continue; continue;
if (field.isVirtualColumn() || field.isEncrypted() || field.isEncryptedColumn()) if ( field.isVirtualColumn()
|| field.isEncrypted()
|| field.isEncryptedColumn()
|| !(field.isDisplayed() || field.isDisplayedGrid()))
continue; continue;
if (field.isParentValue() || (!field.isReadOnly() && field.isDisplayedGrid())) if (field.isParentValue() || (!field.isReadOnly() && field.isDisplayedGrid()))
gridFieldList.add(field); gridFieldList.add(field);

View File

@ -810,9 +810,8 @@ public class GridTabCSVImporter implements IGridTabImporter
if (header.get(i).contains(MTable.getTableName(Env.getCtx(),MLocation.Table_ID))) if (header.get(i).contains(MTable.getTableName(Env.getCtx(),MLocation.Table_ID)))
{ {
//without Region or Country any address would be invalid //without Country any address would be invalid
boolean thereIsCountry = false ; boolean thereIsCountry = false ;
boolean thereIsRegion = false;
boolean isEmptyRow = true; boolean isEmptyRow = true;
for(int j= i;j< header.size();j++){ for(int j= i;j< header.size();j++){
if(!header.get(j).contains(MTable.getTableName(Env.getCtx(),MLocation.Table_ID))) if(!header.get(j).contains(MTable.getTableName(Env.getCtx(),MLocation.Table_ID)))
@ -826,8 +825,6 @@ public class GridTabCSVImporter implements IGridTabImporter
String columnName = header.get(j); String columnName = header.get(j);
Object value = tmpRow.get(j); Object value = tmpRow.get(j);
if(value!=null){ if(value!=null){
if(columnName.contains("RegionName")||columnName.contains("C_Region_ID"))
thereIsRegion = true;
if(columnName.contains("C_Country_ID")) if(columnName.contains("C_Country_ID"))
thereIsCountry= true; thereIsCountry= true;
}else }else
@ -849,8 +846,8 @@ public class GridTabCSVImporter implements IGridTabImporter
isEmptyRow=false; isEmptyRow=false;
} }
MColumn column = MColumn.get(Env.getCtx(), field.getAD_Column_ID()); MColumn column = MColumn.get(Env.getCtx(), field.getAD_Column_ID());
if((field.isMandatory(true) || column.isMandatory()) && !isEmptyRow && (!thereIsRegion || !thereIsCountry)) if((field.isMandatory(true) || column.isMandatory()) && !isEmptyRow && !thereIsCountry)
return new StringBuilder(Msg.getMsg(Env.getCtx(), "FillMandatory")+" "+field.getColumnName()+"["+(thereIsRegion==true?"Region":"C_Country_ID")+"]"); return new StringBuilder(Msg.getMsg(Env.getCtx(), "FillMandatory")+" "+field.getColumnName()+"["+"C_Country_ID]");
} }
return null; return null;
} }

View File

@ -901,7 +901,11 @@ public class ModelClassGenerator
.append("WHERE (TableName IN ('RV_WarehousePrice','RV_BPartner')") // special views .append("WHERE (TableName IN ('RV_WarehousePrice','RV_BPartner')") // special views
.append(" OR IsView='N')") .append(" OR IsView='N')")
.append(" AND IsActive = 'Y' AND TableName NOT LIKE '%_Trl' "); .append(" AND IsActive = 'Y' AND TableName NOT LIKE '%_Trl' ");
// Autodetect if we need to use IN or LIKE clause - teo_sarca [ 3020640 ]
if (tableLike.indexOf(",") == -1)
sql.append(" AND TableName LIKE ").append(tableLike); sql.append(" AND TableName LIKE ").append(tableLike);
else
sql.append(" AND TableName IN (").append(tableLike).append(")"); // only specific tables
sql.append(" AND ").append(entityTypeFilter.toString()); sql.append(" AND ").append(entityTypeFilter.toString());
sql.append(" ORDER BY TableName"); sql.append(" ORDER BY TableName");

View File

@ -823,7 +823,11 @@ public class ModelInterfaceGenerator
.append("WHERE (TableName IN ('RV_WarehousePrice','RV_BPartner')") // special views .append("WHERE (TableName IN ('RV_WarehousePrice','RV_BPartner')") // special views
.append(" OR IsView='N')") .append(" OR IsView='N')")
.append(" AND IsActive = 'Y' AND TableName NOT LIKE '%_Trl' "); .append(" AND IsActive = 'Y' AND TableName NOT LIKE '%_Trl' ");
// Autodetect if we need to use IN or LIKE clause - teo_sarca [ 3020640 ]
if (tableLike.indexOf(",") == -1)
sql.append(" AND TableName LIKE ").append(tableLike); sql.append(" AND TableName LIKE ").append(tableLike);
else
sql.append(" AND TableName IN (").append(tableLike).append(")"); // only specific tables
sql.append(" AND ").append(entityTypeFilter.toString()); sql.append(" AND ").append(entityTypeFilter.toString());
sql.append(" ORDER BY TableName"); sql.append(" ORDER BY TableName");

View File

@ -1402,7 +1402,7 @@ public class GridTab implements DataStatusListener, Evaluatee, Serializable
if (!isDetail()) if (!isDetail())
return true; return true;
// Same link column value // Same link column value
String value = Env.getContext(m_vo.ctx, m_vo.WindowNo, getLinkColumnName()); String value = Env.getContext(m_vo.ctx, m_vo.WindowNo, this.getParentTabNo(), getLinkColumnName());
return m_linkValue.equals(value); return m_linkValue.equals(value);
} // isCurrent } // isCurrent

View File

@ -437,6 +437,20 @@ public class MAllocationHdr extends X_C_AllocationHdr implements DocAction
m_processMsg = "No Business Partner"; m_processMsg = "No Business Partner";
return DocAction.STATUS_Invalid; return DocAction.STATUS_Invalid;
} }
// IDEMPIERE-1850 - validate date against related docs
if (line.getC_Invoice_ID() > 0) {
if (line.getC_Invoice().getDateAcct().after(getDateAcct())) {
m_processMsg = "Wrong allocation date";
return DocAction.STATUS_Invalid;
}
}
if (line.getC_Payment_ID() > 0) {
if (line.getC_Payment().getDateAcct().after(getDateAcct())) {
m_processMsg = "Wrong allocation date";
return DocAction.STATUS_Invalid;
}
}
} }
setApprovalAmt(approval); setApprovalAmt(approval);
// //

View File

@ -27,6 +27,7 @@ import org.compiere.util.DB;
import org.compiere.util.DisplayType; import org.compiere.util.DisplayType;
import org.compiere.util.Env; import org.compiere.util.Env;
import org.compiere.util.Msg; import org.compiere.util.Msg;
import org.compiere.util.Util;
/** /**
* Request Mail Template Model. * Request Mail Template Model.
@ -39,7 +40,7 @@ public class MMailText extends X_R_MailText
/** /**
* *
*/ */
private static final long serialVersionUID = -9121875595478208460L; private static final long serialVersionUID = -3278575461023934790L;
/** /**
* Standard Constructor * Standard Constructor
@ -79,6 +80,7 @@ public class MMailText extends X_R_MailText
private String m_MailText3 = null; private String m_MailText3 = null;
/** Translation Cache */ /** Translation Cache */
private static CCache<String,MMailTextTrl> s_cacheTrl = new CCache<String,MMailTextTrl> (Table_Name, 20); private static CCache<String,MMailTextTrl> s_cacheTrl = new CCache<String,MMailTextTrl> (Table_Name, 20);
private String m_language = null;
/** /**
* Get parsed/translated Mail Text * Get parsed/translated Mail Text
@ -323,13 +325,19 @@ public class MMailText extends X_R_MailText
*/ */
private void translate() private void translate()
{ {
if (m_bpartner != null && m_bpartner.getAD_Language() != null) // Default if no Translation
m_MailHeader = super.getMailHeader();
m_MailText = super.getMailText();
m_MailText2 = super.getMailText2();
m_MailText3 = super.getMailText3();
if ((m_bpartner != null && m_bpartner.getAD_Language() != null) || !Util.isEmpty(m_language))
{ {
StringBuilder key = new StringBuilder().append(m_bpartner.getAD_Language()).append(get_ID()); String adLanguage = m_bpartner != null ? m_bpartner.getAD_Language() : m_language;
StringBuilder key = new StringBuilder().append(adLanguage).append(get_ID());
MMailTextTrl trl = s_cacheTrl.get(key.toString()); MMailTextTrl trl = s_cacheTrl.get(key.toString());
if (trl == null) if (trl == null)
{ {
trl = getTranslation(m_bpartner.getAD_Language()); trl = getTranslation(adLanguage);
if (trl != null) if (trl != null)
s_cacheTrl.put(key.toString(), trl); s_cacheTrl.put(key.toString(), trl);
} }
@ -341,11 +349,6 @@ public class MMailText extends X_R_MailText
m_MailText3 = trl.MailText3; m_MailText3 = trl.MailText3;
} }
} }
// No Translation
m_MailHeader = super.getMailHeader();
m_MailText = super.getMailText();
m_MailText2 = super.getMailText2();
m_MailText3 = super.getMailText3();
} // translate } // translate
/** /**
@ -406,4 +409,9 @@ public class MMailText extends X_R_MailText
String MailText3 = null; String MailText3 = null;
} // MMailTextTrl } // MMailTextTrl
public void setLanguage(String language)
{
m_language = language;
}
} // MMailText } // MMailText

View File

@ -27,6 +27,7 @@ import org.compiere.util.DB;
import org.compiere.util.DisplayType; import org.compiere.util.DisplayType;
import org.compiere.util.Env; import org.compiere.util.Env;
import org.compiere.util.NamePair; import org.compiere.util.NamePair;
import org.compiere.util.Util;
import org.compiere.util.ValueNamePair; import org.compiere.util.ValueNamePair;
/** /**
@ -35,24 +36,23 @@ import org.compiere.util.ValueNamePair;
* *
*/ */
public class MPaymentLookup extends Lookup implements Serializable { public class MPaymentLookup extends Lookup implements Serializable {
/** /**
* *
*/ */
private static final long serialVersionUID = -6863672221350217533L; private static final long serialVersionUID = 6505672741140583659L;
/** Context */ /** Context */
private Properties m_ctx; private Properties m_ctx;
/** IsSOTrx */ /** IsSOTrx */
private boolean m_isSOTrx = false; private boolean m_isSOTrx = false;
/** AD_Column_ID */ /** Validation Code */
private int m_AD_Column_ID; private String m_validationCode;
public MPaymentLookup(Properties ctx, int windowNo, int columnID) { public MPaymentLookup(Properties ctx, int windowNo, String validationCode) {
super(DisplayType.TableDir, windowNo); super(DisplayType.TableDir, windowNo);
m_ctx = ctx; m_ctx = ctx;
m_AD_Column_ID = columnID;
m_isSOTrx = "Y".equals(Env.getContext(Env.getCtx(), windowNo, "IsSOTrx")); m_isSOTrx = "Y".equals(Env.getContext(Env.getCtx(), windowNo, "IsSOTrx"));
m_validationCode = validationCode;
} }
@Override @Override
@ -159,15 +159,9 @@ public class MPaymentLookup extends Lookup implements Serializable {
public String getValidation() public String getValidation()
{ {
StringBuilder sb = new StringBuilder(); if (Util.isEmpty(m_validationCode, true))
sb.append("SELECT vr.Code ");
sb.append("FROM AD_Column c");
sb.append(" LEFT OUTER JOIN AD_Val_Rule vr ON (c.AD_Val_Rule_ID=vr.AD_Val_Rule_ID) ");
sb.append("WHERE c.AD_Column_ID=?");
String validation = DB.getSQLValueString(null, sb.toString(), m_AD_Column_ID);
if (validation == null)
return ""; return "";
return validation.trim(); return m_validationCode.trim();
} }
private String getWhereClause() private String getWhereClause()

View File

@ -25,6 +25,7 @@ import java.sql.PreparedStatement;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.sql.SQLException; import java.sql.SQLException;
import java.util.Properties; import java.util.Properties;
import java.util.UUID;
import java.util.logging.Level; import java.util.logging.Level;
import org.adempiere.exceptions.AdempiereException; import org.adempiere.exceptions.AdempiereException;
@ -345,20 +346,20 @@ public final class MSetup
* Create User-Role * Create User-Role
*/ */
// ClientUser - Admin & User // ClientUser - Admin & User
sql = "INSERT INTO AD_User_Roles(" + m_stdColumns + ",AD_User_ID,AD_Role_ID)" sql = "INSERT INTO AD_User_Roles(" + m_stdColumns + ",AD_User_ID,AD_Role_ID,AD_User_Roles_UU)"
+ " VALUES (" + m_stdValues + "," + AD_User_ID + "," + admin.getAD_Role_ID() + ")"; + " VALUES (" + m_stdValues + "," + AD_User_ID + "," + admin.getAD_Role_ID() + "," + DB.TO_STRING(UUID.randomUUID().toString()) + ")";
no = DB.executeUpdate(sql, m_trx.getTrxName()); no = DB.executeUpdateEx(sql, m_trx.getTrxName());
if (no != 1) if (no != 1)
log.log(Level.SEVERE, "UserRole ClientUser+Admin NOT inserted"); log.log(Level.SEVERE, "UserRole ClientUser+Admin NOT inserted");
sql = "INSERT INTO AD_User_Roles(" + m_stdColumns + ",AD_User_ID,AD_Role_ID)" sql = "INSERT INTO AD_User_Roles(" + m_stdColumns + ",AD_User_ID,AD_Role_ID,AD_User_Roles_UU)"
+ " VALUES (" + m_stdValues + "," + AD_User_ID + "," + user.getAD_Role_ID() + ")"; + " VALUES (" + m_stdValues + "," + AD_User_ID + "," + user.getAD_Role_ID() + "," + DB.TO_STRING(UUID.randomUUID().toString()) + ")";
no = DB.executeUpdate(sql, m_trx.getTrxName()); no = DB.executeUpdateEx(sql, m_trx.getTrxName());
if (no != 1) if (no != 1)
log.log(Level.SEVERE, "UserRole ClientUser+User NOT inserted"); log.log(Level.SEVERE, "UserRole ClientUser+User NOT inserted");
// OrgUser - User // OrgUser - User
sql = "INSERT INTO AD_User_Roles(" + m_stdColumns + ",AD_User_ID,AD_Role_ID)" sql = "INSERT INTO AD_User_Roles(" + m_stdColumns + ",AD_User_ID,AD_Role_ID,AD_User_Roles_UU)"
+ " VALUES (" + m_stdValues + "," + AD_User_U_ID + "," + user.getAD_Role_ID() + ")"; + " VALUES (" + m_stdValues + "," + AD_User_U_ID + "," + user.getAD_Role_ID() + "," + DB.TO_STRING(UUID.randomUUID().toString()) + ")";
no = DB.executeUpdate(sql, m_trx.getTrxName()); no = DB.executeUpdateEx(sql, m_trx.getTrxName());
if (no != 1) if (no != 1)
log.log(Level.SEVERE, "UserRole OrgUser+Org NOT inserted"); log.log(Level.SEVERE, "UserRole OrgUser+Org NOT inserted");
@ -564,11 +565,11 @@ public final class MSetup
{ {
sqlCmd = new StringBuffer ("INSERT INTO C_AcctSchema_Element("); sqlCmd = new StringBuffer ("INSERT INTO C_AcctSchema_Element(");
sqlCmd.append(m_stdColumns).append(",C_AcctSchema_Element_ID,C_AcctSchema_ID,") sqlCmd.append(m_stdColumns).append(",C_AcctSchema_Element_ID,C_AcctSchema_ID,")
.append("ElementType,Name,SeqNo,IsMandatory,IsBalanced) VALUES ("); .append("ElementType,Name,SeqNo,IsMandatory,IsBalanced,C_AcctSchema_Element_UU) VALUES (");
sqlCmd.append(m_stdValues).append(",").append(C_AcctSchema_Element_ID).append(",").append(m_as.getC_AcctSchema_ID()).append(",") sqlCmd.append(m_stdValues).append(",").append(C_AcctSchema_Element_ID).append(",").append(m_as.getC_AcctSchema_ID()).append(",")
.append("'").append(ElementType).append("','").append(name).append("',").append(SeqNo).append(",'") .append("'").append(ElementType).append("','").append(name).append("',").append(SeqNo).append(",'")
.append(IsMandatory).append("','").append(IsBalanced).append("')"); .append(IsMandatory).append("','").append(IsBalanced).append("',").append(DB.TO_STRING(UUID.randomUUID().toString())).append(")");
no = DB.executeUpdate(sqlCmd.toString(), m_trx.getTrxName()); no = DB.executeUpdateEx(sqlCmd.toString(), m_trx.getTrxName());
if (no == 1) if (no == 1)
m_info.append(Msg.translate(m_lang, "C_AcctSchema_Element_ID")).append("=").append(name).append("\n"); m_info.append(Msg.translate(m_lang, "C_AcctSchema_Element_ID")).append("=").append(name).append("\n");
@ -577,7 +578,7 @@ public final class MSetup
{ {
sqlCmd = new StringBuffer ("UPDATE C_AcctSchema_Element SET Org_ID="); sqlCmd = new StringBuffer ("UPDATE C_AcctSchema_Element SET Org_ID=");
sqlCmd.append(getAD_Org_ID()).append(" WHERE C_AcctSchema_Element_ID=").append(C_AcctSchema_Element_ID); sqlCmd.append(getAD_Org_ID()).append(" WHERE C_AcctSchema_Element_ID=").append(C_AcctSchema_Element_ID);
no = DB.executeUpdate(sqlCmd.toString(), m_trx.getTrxName()); no = DB.executeUpdateEx(sqlCmd.toString(), m_trx.getTrxName());
if (no != 1) if (no != 1)
log.log(Level.SEVERE, "Default Org in AcctSchemaElement NOT updated"); log.log(Level.SEVERE, "Default Org in AcctSchemaElement NOT updated");
} }
@ -586,7 +587,7 @@ public final class MSetup
sqlCmd = new StringBuffer ("UPDATE C_AcctSchema_Element SET C_ElementValue_ID="); sqlCmd = new StringBuffer ("UPDATE C_AcctSchema_Element SET C_ElementValue_ID=");
sqlCmd.append(C_ElementValue_ID).append(", C_Element_ID=").append(C_Element_ID); sqlCmd.append(C_ElementValue_ID).append(", C_Element_ID=").append(C_Element_ID);
sqlCmd.append(" WHERE C_AcctSchema_Element_ID=").append(C_AcctSchema_Element_ID); sqlCmd.append(" WHERE C_AcctSchema_Element_ID=").append(C_AcctSchema_Element_ID);
no = DB.executeUpdate(sqlCmd.toString(), m_trx.getTrxName()); no = DB.executeUpdateEx(sqlCmd.toString(), m_trx.getTrxName());
if (no != 1) if (no != 1)
log.log(Level.SEVERE, "Default Account in AcctSchemaElement NOT updated"); log.log(Level.SEVERE, "Default Account in AcctSchemaElement NOT updated");
} }
@ -769,7 +770,7 @@ public final class MSetup
sqlCmd.append("C_AcctSchema1_ID=").append(m_as.getC_AcctSchema_ID()) sqlCmd.append("C_AcctSchema1_ID=").append(m_as.getC_AcctSchema_ID())
.append(", C_Calendar_ID=").append(m_calendar.getC_Calendar_ID()) .append(", C_Calendar_ID=").append(m_calendar.getC_Calendar_ID())
.append(" WHERE AD_Client_ID=").append(m_client.getAD_Client_ID()); .append(" WHERE AD_Client_ID=").append(m_client.getAD_Client_ID());
no = DB.executeUpdate(sqlCmd.toString(), m_trx.getTrxName()); no = DB.executeUpdateEx(sqlCmd.toString(), m_trx.getTrxName());
if (no != 1) if (no != 1)
{ {
String err = "ClientInfo not updated"; String err = "ClientInfo not updated";
@ -986,19 +987,19 @@ public final class MSetup
int C_Channel_ID = getNextID(getAD_Client_ID(), "C_Channel"); int C_Channel_ID = getNextID(getAD_Client_ID(), "C_Channel");
sqlCmd = new StringBuffer("INSERT INTO C_Channel "); sqlCmd = new StringBuffer("INSERT INTO C_Channel ");
sqlCmd.append("(C_Channel_ID,Name,"); sqlCmd.append("(C_Channel_ID,Name,");
sqlCmd.append(m_stdColumns).append(") VALUES ("); sqlCmd.append(m_stdColumns).append(",C_Channel_UU) VALUES (");
sqlCmd.append(C_Channel_ID).append(",").append(defaultEntry); sqlCmd.append(C_Channel_ID).append(",").append(defaultEntry);
sqlCmd.append(m_stdValues).append(")"); sqlCmd.append(m_stdValues).append(",").append(DB.TO_STRING(UUID.randomUUID().toString())).append(")");
no = DB.executeUpdate(sqlCmd.toString(), m_trx.getTrxName()); no = DB.executeUpdateEx(sqlCmd.toString(), m_trx.getTrxName());
if (no != 1) if (no != 1)
log.log(Level.SEVERE, "Channel NOT inserted"); log.log(Level.SEVERE, "Channel NOT inserted");
int C_Campaign_ID = getNextID(getAD_Client_ID(), "C_Campaign"); int C_Campaign_ID = getNextID(getAD_Client_ID(), "C_Campaign");
sqlCmd = new StringBuffer("INSERT INTO C_Campaign "); sqlCmd = new StringBuffer("INSERT INTO C_Campaign ");
sqlCmd.append("(C_Campaign_ID,C_Channel_ID,").append(m_stdColumns).append(","); sqlCmd.append("(C_Campaign_ID,C_Channel_ID,").append(m_stdColumns).append(",");
sqlCmd.append(" Value,Name,Costs) VALUES ("); sqlCmd.append(" Value,Name,Costs,C_Campaign_UU) VALUES (");
sqlCmd.append(C_Campaign_ID).append(",").append(C_Channel_ID).append(",").append(m_stdValues).append(","); sqlCmd.append(C_Campaign_ID).append(",").append(C_Channel_ID).append(",").append(m_stdValues).append(",");
sqlCmd.append(defaultEntry).append(defaultEntry).append("0)"); sqlCmd.append(defaultEntry).append(defaultEntry).append("0").append(",").append(DB.TO_STRING(UUID.randomUUID().toString())).append(")");
no = DB.executeUpdate(sqlCmd.toString(), m_trx.getTrxName()); no = DB.executeUpdateEx(sqlCmd.toString(), m_trx.getTrxName());
if (no == 1) if (no == 1)
m_info.append(Msg.translate(m_lang, "C_Campaign_ID")).append("=").append(defaultName).append("\n"); m_info.append(Msg.translate(m_lang, "C_Campaign_ID")).append("=").append(defaultName).append("\n");
else else
@ -1010,7 +1011,7 @@ public final class MSetup
sqlCmd.append("C_Campaign_ID=").append(C_Campaign_ID); sqlCmd.append("C_Campaign_ID=").append(C_Campaign_ID);
sqlCmd.append(" WHERE C_AcctSchema_ID=").append(m_as.getC_AcctSchema_ID()); sqlCmd.append(" WHERE C_AcctSchema_ID=").append(m_as.getC_AcctSchema_ID());
sqlCmd.append(" AND ElementType='MC'"); sqlCmd.append(" AND ElementType='MC'");
no = DB.executeUpdate(sqlCmd.toString(), m_trx.getTrxName()); no = DB.executeUpdateEx(sqlCmd.toString(), m_trx.getTrxName());
if (no != 1) if (no != 1)
log.log(Level.SEVERE, "AcctSchema ELement Campaign NOT updated"); log.log(Level.SEVERE, "AcctSchema ELement Campaign NOT updated");
} }
@ -1019,10 +1020,10 @@ public final class MSetup
int C_SalesRegion_ID = getNextID(getAD_Client_ID(), "C_SalesRegion"); int C_SalesRegion_ID = getNextID(getAD_Client_ID(), "C_SalesRegion");
sqlCmd = new StringBuffer ("INSERT INTO C_SalesRegion "); sqlCmd = new StringBuffer ("INSERT INTO C_SalesRegion ");
sqlCmd.append("(C_SalesRegion_ID,").append(m_stdColumns).append(","); sqlCmd.append("(C_SalesRegion_ID,").append(m_stdColumns).append(",");
sqlCmd.append(" Value,Name,IsSummary) VALUES ("); sqlCmd.append(" Value,Name,IsSummary,C_SalesRegion_UU) VALUES (");
sqlCmd.append(C_SalesRegion_ID).append(",").append(m_stdValues).append(", "); sqlCmd.append(C_SalesRegion_ID).append(",").append(m_stdValues).append(", ");
sqlCmd.append(defaultEntry).append(defaultEntry).append("'N')"); sqlCmd.append(defaultEntry).append(defaultEntry).append("'N'").append(",").append(DB.TO_STRING(UUID.randomUUID().toString())).append(")");
no = DB.executeUpdate(sqlCmd.toString(), m_trx.getTrxName()); no = DB.executeUpdateEx(sqlCmd.toString(), m_trx.getTrxName());
if (no == 1) if (no == 1)
m_info.append(Msg.translate(m_lang, "C_SalesRegion_ID")).append("=").append(defaultName).append("\n"); m_info.append(Msg.translate(m_lang, "C_SalesRegion_ID")).append("=").append(defaultName).append("\n");
else else
@ -1034,7 +1035,7 @@ public final class MSetup
sqlCmd.append("C_SalesRegion_ID=").append(C_SalesRegion_ID); sqlCmd.append("C_SalesRegion_ID=").append(C_SalesRegion_ID);
sqlCmd.append(" WHERE C_AcctSchema_ID=").append(m_as.getC_AcctSchema_ID()); sqlCmd.append(" WHERE C_AcctSchema_ID=").append(m_as.getC_AcctSchema_ID());
sqlCmd.append(" AND ElementType='SR'"); sqlCmd.append(" AND ElementType='SR'");
no = DB.executeUpdate(sqlCmd.toString(), m_trx.getTrxName()); no = DB.executeUpdateEx(sqlCmd.toString(), m_trx.getTrxName());
if (no != 1) if (no != 1)
log.log(Level.SEVERE, "AcctSchema ELement SalesRegion NOT updated"); log.log(Level.SEVERE, "AcctSchema ELement SalesRegion NOT updated");
} }
@ -1073,7 +1074,7 @@ public final class MSetup
sqlCmd.append("C_BPartner_ID=").append(bp.getC_BPartner_ID()); sqlCmd.append("C_BPartner_ID=").append(bp.getC_BPartner_ID());
sqlCmd.append(" WHERE C_AcctSchema_ID=").append(m_as.getC_AcctSchema_ID()); sqlCmd.append(" WHERE C_AcctSchema_ID=").append(m_as.getC_AcctSchema_ID());
sqlCmd.append(" AND ElementType='BP'"); sqlCmd.append(" AND ElementType='BP'");
no = DB.executeUpdate(sqlCmd.toString(), m_trx.getTrxName()); no = DB.executeUpdateEx(sqlCmd.toString(), m_trx.getTrxName());
if (no != 1) if (no != 1)
log.log(Level.SEVERE, "AcctSchema Element BPartner NOT updated"); log.log(Level.SEVERE, "AcctSchema Element BPartner NOT updated");
createPreference("C_BPartner_ID", String.valueOf(bp.getC_BPartner_ID()), 143); createPreference("C_BPartner_ID", String.valueOf(bp.getC_BPartner_ID()), 143);
@ -1098,13 +1099,14 @@ public final class MSetup
int C_TaxCategory_ID = getNextID(getAD_Client_ID(), "C_TaxCategory"); int C_TaxCategory_ID = getNextID(getAD_Client_ID(), "C_TaxCategory");
sqlCmd = new StringBuffer ("INSERT INTO C_TaxCategory "); sqlCmd = new StringBuffer ("INSERT INTO C_TaxCategory ");
sqlCmd.append("(C_TaxCategory_ID,").append(m_stdColumns).append(","); sqlCmd.append("(C_TaxCategory_ID,").append(m_stdColumns).append(",");
sqlCmd.append(" Name,IsDefault) VALUES ("); sqlCmd.append(" Name,IsDefault,C_TaxCategory_UU) VALUES (");
sqlCmd.append(C_TaxCategory_ID).append(",").append(m_stdValues).append(", "); sqlCmd.append(C_TaxCategory_ID).append(",").append(m_stdValues).append(", ");
if (C_Country_ID == COUNTRY_US) // US if (C_Country_ID == COUNTRY_US) // US
sqlCmd.append("'Sales Tax','Y')"); sqlCmd.append("'Sales Tax','Y',");
else else
sqlCmd.append(defaultEntry).append("'Y')"); sqlCmd.append(defaultEntry).append("'Y',");
no = DB.executeUpdate(sqlCmd.toString(), m_trx.getTrxName()); sqlCmd.append(DB.TO_STRING(UUID.randomUUID().toString())).append(")");
no = DB.executeUpdateEx(sqlCmd.toString(), m_trx.getTrxName());
if (no != 1) if (no != 1)
log.log(Level.SEVERE, "TaxCategory NOT inserted"); log.log(Level.SEVERE, "TaxCategory NOT inserted");
@ -1112,7 +1114,7 @@ public final class MSetup
sqlCmd.append(" SELECT l.AD_Language,t.C_TaxCategory_ID, t.Description,t.Name, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy FROM AD_Language l, C_TaxCategory t"); sqlCmd.append(" SELECT l.AD_Language,t.C_TaxCategory_ID, t.Description,t.Name, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy FROM AD_Language l, C_TaxCategory t");
sqlCmd.append(" WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.C_TaxCategory_ID=").append(C_TaxCategory_ID); sqlCmd.append(" WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.C_TaxCategory_ID=").append(C_TaxCategory_ID);
sqlCmd.append(" AND NOT EXISTS (SELECT * FROM C_TaxCategory_Trl tt WHERE tt.AD_Language=l.AD_Language AND tt.C_TaxCategory_ID=t.C_TaxCategory_ID)"); sqlCmd.append(" AND NOT EXISTS (SELECT * FROM C_TaxCategory_Trl tt WHERE tt.AD_Language=l.AD_Language AND tt.C_TaxCategory_ID=t.C_TaxCategory_ID)");
no = DB.executeUpdate(sqlCmd.toString(), m_trx.getTrxName()); no = DB.executeUpdateEx(sqlCmd.toString(), m_trx.getTrxName());
if (no < 0) if (no < 0)
log.log(Level.SEVERE, "TaxCategory Translation NOT inserted"); log.log(Level.SEVERE, "TaxCategory Translation NOT inserted");
@ -1141,7 +1143,7 @@ public final class MSetup
sqlCmd.append("M_Product_ID=").append(product.getM_Product_ID()); sqlCmd.append("M_Product_ID=").append(product.getM_Product_ID());
sqlCmd.append(" WHERE C_AcctSchema_ID=").append(m_as.getC_AcctSchema_ID()); sqlCmd.append(" WHERE C_AcctSchema_ID=").append(m_as.getC_AcctSchema_ID());
sqlCmd.append(" AND ElementType='PR'"); sqlCmd.append(" AND ElementType='PR'");
no = DB.executeUpdate(sqlCmd.toString(), m_trx.getTrxName()); no = DB.executeUpdateEx(sqlCmd.toString(), m_trx.getTrxName());
if (no != 1) if (no != 1)
log.log(Level.SEVERE, "AcctSchema Element Product NOT updated"); log.log(Level.SEVERE, "AcctSchema Element Product NOT updated");
@ -1155,7 +1157,7 @@ public final class MSetup
loc.saveEx(); loc.saveEx();
sqlCmd = new StringBuffer ("UPDATE AD_OrgInfo SET C_Location_ID="); sqlCmd = new StringBuffer ("UPDATE AD_OrgInfo SET C_Location_ID=");
sqlCmd.append(loc.getC_Location_ID()).append(" WHERE AD_Org_ID=").append(getAD_Org_ID()); sqlCmd.append(loc.getC_Location_ID()).append(" WHERE AD_Org_ID=").append(getAD_Org_ID());
no = DB.executeUpdate(sqlCmd.toString(), m_trx.getTrxName()); no = DB.executeUpdateEx(sqlCmd.toString(), m_trx.getTrxName());
if (no != 1) if (no != 1)
log.log(Level.SEVERE, "Location NOT inserted"); log.log(Level.SEVERE, "Location NOT inserted");
createPreference("C_Country_ID", String.valueOf(C_Country_ID), 0); createPreference("C_Country_ID", String.valueOf(C_Country_ID), 0);
@ -1187,7 +1189,7 @@ public final class MSetup
// sqlCmd.append(",C_UOM_Length_ID="); // sqlCmd.append(",C_UOM_Length_ID=");
// sqlCmd.append(",C_UOM_Time_ID="); // sqlCmd.append(",C_UOM_Time_ID=");
sqlCmd.append(" WHERE AD_Client_ID=").append(getAD_Client_ID()); sqlCmd.append(" WHERE AD_Client_ID=").append(getAD_Client_ID());
no = DB.executeUpdate(sqlCmd.toString(), m_trx.getTrxName()); no = DB.executeUpdateEx(sqlCmd.toString(), m_trx.getTrxName());
if (no != 1) if (no != 1)
{ {
String err = "ClientInfo not updated"; String err = "ClientInfo not updated";
@ -1246,7 +1248,7 @@ public final class MSetup
// Update User // Update User
sqlCmd = new StringBuffer ("UPDATE AD_User SET C_BPartner_ID="); sqlCmd = new StringBuffer ("UPDATE AD_User SET C_BPartner_ID=");
sqlCmd.append(bpCU.getC_BPartner_ID()).append(" WHERE AD_User_ID=").append(AD_User_U_ID); sqlCmd.append(bpCU.getC_BPartner_ID()).append(" WHERE AD_User_ID=").append(AD_User_U_ID);
no = DB.executeUpdate(sqlCmd.toString(), m_trx.getTrxName()); no = DB.executeUpdateEx(sqlCmd.toString(), m_trx.getTrxName());
if (no != 1) if (no != 1)
log.log(Level.SEVERE, "User of SalesRep (User) NOT updated"); log.log(Level.SEVERE, "User of SalesRep (User) NOT updated");
@ -1272,7 +1274,7 @@ public final class MSetup
// Update User // Update User
sqlCmd = new StringBuffer ("UPDATE AD_User SET C_BPartner_ID="); sqlCmd = new StringBuffer ("UPDATE AD_User SET C_BPartner_ID=");
sqlCmd.append(bpCA.getC_BPartner_ID()).append(" WHERE AD_User_ID=").append(AD_User_ID); sqlCmd.append(bpCA.getC_BPartner_ID()).append(" WHERE AD_User_ID=").append(AD_User_ID);
no = DB.executeUpdate(sqlCmd.toString(), m_trx.getTrxName()); no = DB.executeUpdateEx(sqlCmd.toString(), m_trx.getTrxName());
if (no != 1) if (no != 1)
log.log(Level.SEVERE, "User of SalesRep (Admin) NOT updated"); log.log(Level.SEVERE, "User of SalesRep (Admin) NOT updated");
@ -1281,10 +1283,10 @@ public final class MSetup
int C_PaymentTerm_ID = getNextID(getAD_Client_ID(), "C_PaymentTerm"); int C_PaymentTerm_ID = getNextID(getAD_Client_ID(), "C_PaymentTerm");
sqlCmd = new StringBuffer ("INSERT INTO C_PaymentTerm "); sqlCmd = new StringBuffer ("INSERT INTO C_PaymentTerm ");
sqlCmd.append("(C_PaymentTerm_ID,").append(m_stdColumns).append(","); sqlCmd.append("(C_PaymentTerm_ID,").append(m_stdColumns).append(",");
sqlCmd.append("Value,Name,NetDays,GraceDays,DiscountDays,Discount,DiscountDays2,Discount2,IsDefault) VALUES ("); sqlCmd.append("Value,Name,NetDays,GraceDays,DiscountDays,Discount,DiscountDays2,Discount2,IsDefault,C_PaymentTerm_UU) VALUES (");
sqlCmd.append(C_PaymentTerm_ID).append(",").append(m_stdValues).append(","); sqlCmd.append(C_PaymentTerm_ID).append(",").append(m_stdValues).append(",");
sqlCmd.append("'Immediate','Immediate',0,0,0,0,0,0,'Y')"); sqlCmd.append("'Immediate','Immediate',0,0,0,0,0,0,'Y'").append(",").append(DB.TO_STRING(UUID.randomUUID().toString())).append(")");
no = DB.executeUpdate(sqlCmd.toString(), m_trx.getTrxName()); no = DB.executeUpdateEx(sqlCmd.toString(), m_trx.getTrxName());
if (no != 1) if (no != 1)
log.log(Level.SEVERE, "PaymentTerm NOT inserted"); log.log(Level.SEVERE, "PaymentTerm NOT inserted");
@ -1292,10 +1294,10 @@ public final class MSetup
C_Cycle_ID = getNextID(getAD_Client_ID(), "C_Cycle"); C_Cycle_ID = getNextID(getAD_Client_ID(), "C_Cycle");
sqlCmd = new StringBuffer ("INSERT INTO C_Cycle "); sqlCmd = new StringBuffer ("INSERT INTO C_Cycle ");
sqlCmd.append("(C_Cycle_ID,").append(m_stdColumns).append(","); sqlCmd.append("(C_Cycle_ID,").append(m_stdColumns).append(",");
sqlCmd.append(" Name,C_Currency_ID) VALUES ("); sqlCmd.append(" Name,C_Currency_ID,C_Cycle_UU) VALUES (");
sqlCmd.append(C_Cycle_ID).append(",").append(m_stdValues).append(", "); sqlCmd.append(C_Cycle_ID).append(",").append(m_stdValues).append(", ");
sqlCmd.append(defaultEntry).append(C_Currency_ID).append(")"); sqlCmd.append(defaultEntry).append(C_Currency_ID).append(",").append(DB.TO_STRING(UUID.randomUUID().toString())).append(")");
no = DB.executeUpdate(sqlCmd.toString(), m_trx.getTrxName()); no = DB.executeUpdateEx(sqlCmd.toString(), m_trx.getTrxName());
if (no != 1) if (no != 1)
log.log(Level.SEVERE, "Cycle NOT inserted"); log.log(Level.SEVERE, "Cycle NOT inserted");
@ -1307,10 +1309,10 @@ public final class MSetup
int C_Project_ID = getNextID(getAD_Client_ID(), "C_Project"); int C_Project_ID = getNextID(getAD_Client_ID(), "C_Project");
sqlCmd = new StringBuffer ("INSERT INTO C_Project "); sqlCmd = new StringBuffer ("INSERT INTO C_Project ");
sqlCmd.append("(C_Project_ID,").append(m_stdColumns).append(","); sqlCmd.append("(C_Project_ID,").append(m_stdColumns).append(",");
sqlCmd.append(" Value,Name,C_Currency_ID,IsSummary) VALUES ("); sqlCmd.append(" Value,Name,C_Currency_ID,IsSummary,C_Project_UU) VALUES (");
sqlCmd.append(C_Project_ID).append(",").append(m_stdValuesOrg).append(", "); sqlCmd.append(C_Project_ID).append(",").append(m_stdValuesOrg).append(", ");
sqlCmd.append(defaultEntry).append(defaultEntry).append(C_Currency_ID).append(",'N')"); sqlCmd.append(defaultEntry).append(defaultEntry).append(C_Currency_ID).append(",'N'").append(",").append(DB.TO_STRING(UUID.randomUUID().toString())).append(")");
no = DB.executeUpdate(sqlCmd.toString(), m_trx.getTrxName()); no = DB.executeUpdateEx(sqlCmd.toString(), m_trx.getTrxName());
if (no == 1) if (no == 1)
m_info.append(Msg.translate(m_lang, "C_Project_ID")).append("=").append(defaultName).append("\n"); m_info.append(Msg.translate(m_lang, "C_Project_ID")).append("=").append(defaultName).append("\n");
else else
@ -1322,7 +1324,7 @@ public final class MSetup
sqlCmd.append("C_Project_ID=").append(C_Project_ID); sqlCmd.append("C_Project_ID=").append(C_Project_ID);
sqlCmd.append(" WHERE C_AcctSchema_ID=").append(m_as.getC_AcctSchema_ID()); sqlCmd.append(" WHERE C_AcctSchema_ID=").append(m_as.getC_AcctSchema_ID());
sqlCmd.append(" AND ElementType='PJ'"); sqlCmd.append(" AND ElementType='PJ'");
no = DB.executeUpdate(sqlCmd.toString(), m_trx.getTrxName()); no = DB.executeUpdateEx(sqlCmd.toString(), m_trx.getTrxName());
if (no != 1) if (no != 1)
log.log(Level.SEVERE, "AcctSchema ELement Project NOT updated"); log.log(Level.SEVERE, "AcctSchema ELement Project NOT updated");
} }
@ -1352,15 +1354,15 @@ public final class MSetup
{ {
int AD_Preference_ID = getNextID(getAD_Client_ID(), "AD_Preference"); int AD_Preference_ID = getNextID(getAD_Client_ID(), "AD_Preference");
StringBuilder sqlCmd = new StringBuilder ("INSERT INTO AD_Preference "); StringBuilder sqlCmd = new StringBuilder ("INSERT INTO AD_Preference ");
sqlCmd.append("(AD_Preference_ID,").append(m_stdColumns).append(","); sqlCmd.append("(AD_Preference_ID,").append("AD_Preference_UU,").append(m_stdColumns).append(",");
sqlCmd.append("Attribute,Value,AD_Window_ID) VALUES ("); sqlCmd.append("Attribute,Value,AD_Window_ID) VALUES (");
sqlCmd.append(AD_Preference_ID).append(",").append(m_stdValues).append(","); sqlCmd.append(AD_Preference_ID).append(",").append(DB.TO_STRING(UUID.randomUUID().toString())).append(",").append(m_stdValues).append(",");
sqlCmd.append("'").append(Attribute).append("','").append(Value).append("',"); sqlCmd.append("'").append(Attribute).append("','").append(Value).append("',");
if (AD_Window_ID == 0) if (AD_Window_ID == 0)
sqlCmd.append("NULL)"); sqlCmd.append("NULL)");
else else
sqlCmd.append(AD_Window_ID).append(")"); sqlCmd.append(AD_Window_ID).append(")");
int no = DB.executeUpdate(sqlCmd.toString(), m_trx.getTrxName()); int no = DB.executeUpdateEx(sqlCmd.toString(), m_trx.getTrxName());
if (no != 1) if (no != 1)
log.log(Level.SEVERE, "Preference NOT inserted - " + Attribute); log.log(Level.SEVERE, "Preference NOT inserted - " + Attribute);
} // createPreference } // createPreference

View File

@ -51,6 +51,7 @@ import org.adempiere.exceptions.DBException;
import org.adempiere.process.UUIDGenerator; import org.adempiere.process.UUIDGenerator;
import org.compiere.Adempiere; import org.compiere.Adempiere;
import org.compiere.acct.Doc; import org.compiere.acct.Doc;
import org.compiere.util.CCache;
import org.compiere.util.CLogMgt; import org.compiere.util.CLogMgt;
import org.compiere.util.CLogger; import org.compiere.util.CLogger;
import org.compiere.util.CacheMgt; import org.compiere.util.CacheMgt;
@ -1876,6 +1877,9 @@ public abstract class PO
set_ValueNoCheck ("UpdatedBy", new Integer(AD_User_ID)); set_ValueNoCheck ("UpdatedBy", new Integer(AD_User_ID));
} // setAD_User_ID } // setAD_User_ID
/** Cache */
private static CCache<String,String> trl_cache = new CCache<String,String>("po_trl", 5);
/** /**
* Get Translation of column (if needed). * Get Translation of column (if needed).
* It checks if the base language is used or the column is not translated. * It checks if the base language is used or the column is not translated.
@ -1899,7 +1903,13 @@ public abstract class PO
+ ", ID=" + m_IDs[0]); + ", ID=" + m_IDs[0]);
} }
String key = get_TableName() + "." + columnName + "|" + get_ID() + "|" + AD_Language;
String retValue = null; String retValue = null;
if (trl_cache.containsKey(key)) {
retValue = trl_cache.get(key);
return retValue;
} else {
// //
// Check if NOT base language and column is translated => load trl from db // Check if NOT base language and column is translated => load trl from db
if (!Env.isBaseLanguage(AD_Language, get_TableName()) if (!Env.isBaseLanguage(AD_Language, get_TableName())
@ -1914,12 +1924,14 @@ public abstract class PO
.append(" AND AD_Language=?"); .append(" AND AD_Language=?");
retValue = DB.getSQLValueString(get_TrxName(), sql.toString(), ID, AD_Language); retValue = DB.getSQLValueString(get_TrxName(), sql.toString(), ID, AD_Language);
} }
}
// //
// If no translation found or not translated, fallback to original: // If no translation found or not translated, fallback to original:
if (retValue == null) { if (retValue == null) {
Object val = get_Value(columnName); Object val = get_Value(columnName);
retValue = (val != null ? val.toString() : null); retValue = (val != null ? val.toString() : null);
} }
trl_cache.put(key, retValue);
// //
return retValue; return retValue;
} // get_Translation } // get_Translation

View File

@ -625,9 +625,6 @@ public class MPrintFormatItem extends X_AD_PrintFormatItem
*/ */
protected boolean beforeSave (boolean newRecord) protected boolean beforeSave (boolean newRecord)
{ {
if (!isPrinted()) {
setIsOrderBy(false);
}
// Order // Order
if (!isOrderBy()) if (!isOrderBy())
{ {

View File

@ -78,7 +78,6 @@ public class BroadcastMsgUtil
if (! user.isActive()) if (! user.isActive())
continue; continue;
MNote note = new MNote(Env.getCtx(), 0, trxName); MNote note = new MNote(Env.getCtx(), 0, trxName);
if (MBroadcastMessage.TARGET_Everybody.equals(mbMessage.getTarget()))
note.setClientOrg(user.getAD_Client_ID(), 0); note.setClientOrg(user.getAD_Client_ID(), 0);
note.setAD_BroadcastMessage_ID(messageID); note.setAD_BroadcastMessage_ID(messageID);
note.setAD_User_ID(userID); note.setAD_User_ID(userID);

View File

@ -190,12 +190,13 @@ public class WindowElementHandler extends AbstractElementHandler {
} }
// Preference Tag // Preference Tag
sql = "SELECT AD_Preference_ID FROM AD_PREFERENCE WHERE AD_WINDOW_ID = ?"; sql = "SELECT AD_Preference_ID FROM AD_PREFERENCE WHERE AD_WINDOW_ID = ? AND AD_CLIENT_ID = ?";
pstmt = null; pstmt = null;
rs = null; rs = null;
try { try {
pstmt = DB.prepareStatement(sql, getTrxName(ctx)); pstmt = DB.prepareStatement(sql, getTrxName(ctx));
pstmt.setInt(1, AD_Window_ID); pstmt.setInt(1, AD_Window_ID);
pstmt.setInt(2, Env.getAD_Client_ID(ctx.ctx));
rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
while (rs.next()) { while (rs.next()) {
createPreference(ctx, document, rs.getInt("AD_Preference_ID")); createPreference(ctx, document, rs.getInt("AD_Preference_ID"));

View File

@ -195,7 +195,6 @@
58600,"Rate Variance","Account for Rate Variance","Expense",,"Yes","No","",58,,,,,,,,,, 58600,"Rate Variance","Account for Rate Variance","Expense",,"Yes","No","",58,,,,,,,,,,
58700,"Mix Variance","Account for Mix Variance","Expense",,"Yes","No","",58,,,,,,,,,, 58700,"Mix Variance","Account for Mix Variance","Expense",,"Yes","No","",58,,,,,,,,,,
58800,"Average Cost Variance","Account for Average Cost Variance","Expense",,"Yes","No","P_AVERAGECOSTVARIANCE_ACCT",58,,,,,,,,,, 58800,"Average Cost Variance","Account for Average Cost Variance","Expense",,"Yes","No","P_AVERAGECOSTVARIANCE_ACCT",58,,,,,,,,,,
58900,"Landed Cost Clearing","Account for Landed Cost Clearing","Expense",,"Yes","No","P_LANDEDCOSTCLEARING_ACCT",58,,,,,,,,,,
59,"CoGs Discounts",,"Expense",,,"Yes",,5,,,,,59,"CoGS Discounts",2,,, 59,"CoGs Discounts",,"Expense",,,"Yes",,5,,,,,59,"CoGS Discounts",2,,,
59100,"Trade discounts received","Received Trade Discounts (corrects Product expense)","Expense",,"Yes","No","P_TRADEDISCOUNTREC_ACCT",59,,,,,,,,,, 59100,"Trade discounts received","Received Trade Discounts (corrects Product expense)","Expense",,"Yes","No","P_TRADEDISCOUNTREC_ACCT",59,,,,,,,,,,
59200,"Payment discount revenue","Granted early payment discount from vendors","Expense",,"Yes","No","PAYDISCOUNT_REV_ACCT",59,,,,,,,,,, 59200,"Payment discount revenue","Granted early payment discount from vendors","Expense",,"Yes","No","PAYDISCOUNT_REV_ACCT",59,,,,,,,,,,

1 [Account_Value] [Account_Name] [Account_Description] [Account_Type] [Account_Sign] [Account_Document] [Account_Summary] [Default_Account] [Account_Parent] [Balance Sheet] [Balance Sheet_Name] [US 1120 Balance Sheet] US 1120 Balance Sheet_Name [Profit & Loss] [Profit & Loss_Name] [US 1120 Income Statement] [US 1120 Income Statement_Name] [Cash Flow] [Cash Flow_Name]
195 58600 Rate Variance Account for Rate Variance Expense Yes No 58
196 58700 Mix Variance Account for Mix Variance Expense Yes No 58
197 58800 Average Cost Variance Account for Average Cost Variance Expense Yes No P_AVERAGECOSTVARIANCE_ACCT 58
58900 Landed Cost Clearing Account for Landed Cost Clearing Expense Yes No P_LANDEDCOSTCLEARING_ACCT 58
198 59 CoGs Discounts Expense Yes 5 59 CoGS Discounts 2
199 59100 Trade discounts received Received Trade Discounts (corrects Product expense) Expense Yes No P_TRADEDISCOUNTREC_ACCT 59
200 59200 Payment discount revenue Granted early payment discount from vendors Expense Yes No PAYDISCOUNT_REV_ACCT 59

View File

@ -10,7 +10,7 @@ echo Export idempiere Database - $IDEMPIERE_HOME \($ADEMPIERE_DB_NAME\)
# Parameter: <adempiereDBuser>/<adempiereDBpassword> # Parameter: <adempiereDBuser>/<adempiereDBpassword>
sh $ADEMPIERE_DB_PATH/DBExport.sh $ADEMPIERE_DB_USER $ADEMPIERE_DB_PASSWORD sh $ADEMPIERE_DB_PATH/DBExport.sh "$ADEMPIERE_DB_USER" "$ADEMPIERE_DB_PASSWORD"
# sh $ADEMPIERE_DB_PATH/DBExportFull.sh system/$ADEMPIERE_DB_SYSTEM # sh $ADEMPIERE_DB_PATH/DBExportFull.sh system/$ADEMPIERE_DB_SYSTEM

View File

@ -16,4 +16,4 @@ read in
# Parameter: <systemAccount> <adempiereID> <adempierePwd> # Parameter: <systemAccount> <adempiereID> <adempierePwd>
# globalqss - cruiz - 2007-10-09 - added fourth parameter for postgres(ignored in oracle) # globalqss - cruiz - 2007-10-09 - added fourth parameter for postgres(ignored in oracle)
$ADEMPIERE_DB_PATH/DBRestore.sh system/$ADEMPIERE_DB_SYSTEM $ADEMPIERE_DB_USER $ADEMPIERE_DB_PASSWORD $ADEMPIERE_DB_SYSTEM $ADEMPIERE_DB_PATH/DBRestore.sh "system/$ADEMPIERE_DB_SYSTEM" "$ADEMPIERE_DB_USER" "$ADEMPIERE_DB_PASSWORD" "$ADEMPIERE_DB_SYSTEM"

View File

@ -38,4 +38,4 @@ read in
# Parameter: <systemAccount> <AdempiereID> <AdempierePwd> # Parameter: <systemAccount> <AdempiereID> <AdempierePwd>
# globalqss - cruiz - 2007-10-09 - added fourth parameter for postgres(ignored in oracle) # globalqss - cruiz - 2007-10-09 - added fourth parameter for postgres(ignored in oracle)
$ADEMPIERE_DB_PATH/ImportIdempiere.sh $SYSUSER/$ADEMPIERE_DB_SYSTEM $ADEMPIERE_DB_USER $ADEMPIERE_DB_PASSWORD $ADEMPIERE_DB_SYSTEM $SUFFIX $ADEMPIERE_DB_PATH/ImportIdempiere.sh "$SYSUSER/$ADEMPIERE_DB_SYSTEM" "$ADEMPIERE_DB_USER" "$ADEMPIERE_DB_PASSWORD" "$ADEMPIERE_DB_SYSTEM" "$SUFFIX"

View File

@ -18,7 +18,7 @@
# initialization # initialization
# adjust these variables to your environment # adjust these variables to your environment
IDEMPIERE_HOME=/home/idempiere/idempiere-server IDEMPIERE_HOME=/opt/idempiere-server
IDEMPIEREUSER=idempiere IDEMPIEREUSER=idempiere
# Instead of using ENVFILE you can set JAVA_HOME, IDEMPIERE_HOME and add JAVA_HOME/bin to PATH # Instead of using ENVFILE you can set JAVA_HOME, IDEMPIERE_HOME and add JAVA_HOME/bin to PATH
# in this case you can comment the source lines for ENVFILE below # in this case you can comment the source lines for ENVFILE below
@ -141,9 +141,6 @@ case "$1" in
stop) stop)
stop stop
;; ;;
reload)
restart
;;
restart) restart)
restart restart
;; ;;
@ -154,7 +151,7 @@ case "$1" in
status status
;; ;;
*) *)
echo $"Usage: $0 {start|stop|reload|restart|condrestart|status}" echo $"Usage: $0 {start|stop|restart|condrestart|status}"
exit 1 exit 1
esac esac

View File

@ -17,7 +17,7 @@
# initialization # initialization
# adjust these variables to your environment # adjust these variables to your environment
IDEMPIERE_HOME=/home/idempiere/idempiere-server IDEMPIERE_HOME=/opt/idempiere-server
ENVFILE=$IDEMPIERE_HOME/utils/myEnvironment.sh ENVFILE=$IDEMPIERE_HOME/utils/myEnvironment.sh
IDEMPIEREUSER=idempiere IDEMPIEREUSER=idempiere
@ -136,9 +136,6 @@ case "$1" in
stop) stop)
stop stop
;; ;;
reload)
restart
;;
restart) restart)
restart restart
;; ;;
@ -149,7 +146,7 @@ case "$1" in
status status
;; ;;
*) *)
echo $"Usage: $0 {start|stop|reload|restart|condrestart|status}" echo $"Usage: $0 {start|stop|restart|condrestart|status}"
exit 1 exit 1
esac esac

View File

@ -0,0 +1,196 @@
#!/bin/sh
# Copyright (c) 2014 Carlos Ruiz - GlobalQSS
# All rights reserved.
#
# System startup script for iDempiere
#
# LSB compatible service control script; see http://www.linuxbase.org/spec/
#
### BEGIN INIT INFO
# Provides: idempiere
# Required-Start:
# Required-Stop:
# Default-Start: 3 5
# Default-Stop:
# Description: Start the iDempiere server
### END INIT INFO
# initialization
# adjust these variables to your environment
IDEMPIERE_HOME=/opt/idempiere-server
IDEMPIEREUSER=idempiere
# Instead of using ENVFILE you can set JAVA_HOME, IDEMPIERE_HOME and add JAVA_HOME/bin to PATH
# in this case you can comment the source lines for ENVFILE below
# detected some problems with Hardy Heron ubuntu using the bash source command
ENVFILE=$IDEMPIERE_HOME/utils/myEnvironment.sh
# Shell functions sourced from /etc/rc.status:
# rc_check check and set local and overall rc status
# rc_status check and set local and overall rc status
# rc_status -v ditto but be verbose in local rc status
# rc_status -v -r ditto and clear the local rc status
# rc_failed set local and overall rc status to failed
# rc_reset clear local rc status (overall remains)
# rc_exit exit appropriate to overall rc status
. /etc/rc.status
# The echo return value for success (defined in /etc/rc.config).
rc_reset
# Return values acc. to LSB for all commands but status:
# 0 - success
# 1 - generic or unspecified error
# 2 - invalid or excess argument(s)
# 3 - unimplemented feature (e.g. "reload")
# 4 - insufficient privilege
# 5 - program is not installed
# 6 - program is not configured
# 7 - program is not running
#
# Note that starting an already running service, stopping
# or restarting a not-running service as well as the restart
# with force-reload (in case signalling is not supported) are
# considered a success.
#
IDEMPIERESTATUS=
MAXITERATIONS=60
getidempierestatus() {
IDEMPIERESTATUSSTRING=$(ps ax | grep -v grep | grep $IDEMPIERE_HOME)
echo $IDEMPIERESTATUSSTRING | grep -q $IDEMPIERE_HOME
IDEMPIERESTATUS=$?
}
start () {
getidempierestatus
if [ $IDEMPIERESTATUS -eq 0 ] ; then
echo "iDempiere is already running"
rc_failed 0
return
fi
echo -n "Starting iDempiere ERP: "
cd $IDEMPIERE_HOME/utils
. $ENVFILE
export LOGFILE=$IDEMPIERE_HOME/log/idempiere_`date +%Y%m%d%H%M%S`.log
su $IDEMPIEREUSER -c "mkdir -p IDEMPIERE_HOME/log"
su $IDEMPIEREUSER -c "cd $IDEMPIERE_HOME;$IDEMPIERE_HOME/idempiere-server.sh &> $LOGFILE &"
RETVAL=$?
if [ $RETVAL -eq 0 ] ; then
# wait for server to be confirmed as started in logfile
STATUSTEST=0
ITERATIONS=0
while [ $STATUSTEST -eq 0 ] ; do
sleep 2
tail -n 9 $LOGFILE | grep -q '.*WebUIServlet.*started successfully.*' && STATUSTEST=1
echo -n "."
ITERATIONS=`expr $ITERATIONS + 1`
if [ $ITERATIONS -gt $MAXITERATIONS ]
then
break
fi
done
if [ $STATUSTEST -eq 0 ]
then
echo "Service hasn't started within the timeout allowed, please review file $LOGFILE to see the status of the service"
rc_failed 1
else
echo "Service started"
fi
echo
else
echo "Service not started"
rc_failed 1
fi
rc_status -v
}
stop () {
getidempierestatus
if [ $IDEMPIERESTATUS -ne 0 ] ; then
echo "iDempiere is already stopped"
rc_failed 0
return
fi
echo -n "Stopping iDempiere ERP: "
cd $IDEMPIERE_HOME/utils
. $ENVFILE
echo "Trying direct kill with signal -15"
# try direct kill with signal 15, then signal 9
kill -15 -`ps ax o pgid,command | grep -v grep | grep $IDEMPIERE_HOME | sed -e 's/^ *//g' | cut -f 1 -d " " | sort -u`
sleep 5
getidempierestatus
if [ $IDEMPIERESTATUS -ne 0 ] ; then
echo "Service stopped with kill -15"
else
echo "Trying direct kill with signal -9"
kill -9 -`ps ax o pgid,command | grep -v grep | grep $IDEMPIERE_HOME | sed -e 's/^ *//g' | cut -f 1 -d " " | sort -u`
sleep 5
getidempierestatus
if [ $IDEMPIERESTATUS -ne 0 ] ; then
echo "Service stopped with kill -9"
else
echo "Service hasn't stopped"
rc_failed 1
fi
fi
rc_status -v
}
restart () {
stop
sleep 1
start
rc_status
}
condrestart () {
getidempierestatus
if [ $IDEMPIERESTATUS -eq 0 ] ; then
restart
else
rc_reset # Not running is not a failure.
fi
rc_status
}
status () {
getidempierestatus
if [ $IDEMPIERESTATUS -eq 0 ] ; then
echo
echo "iDempiere is running:"
ps ax | grep -v grep | grep $IDEMPIERE_HOME | sed 's/^[[:space:]]*\([[:digit:]]*\).*:[[:digit:]][[:digit:]][[:space:]]\(.*\)/\1 \2/'
echo
else
echo "iDempiere is stopped"
rc_failed 3
fi
rc_status -v
}
case "$1" in
start)
start
;;
stop)
stop
;;
reload)
restart
;;
restart)
restart
;;
condrestart)
condrestart
;;
status)
status
;;
*)
echo $"Usage: $0 {start|stop|reload|restart|condrestart|status}"
exit 1
esac
# Inform the caller not only verbosely and set an exit status.
rc_exit

View File

@ -28,11 +28,11 @@ import org.jfree.data.time.TimeSeriesCollection;
import org.jfree.data.time.TimeSeriesDataItem; import org.jfree.data.time.TimeSeriesDataItem;
public class VChart extends CPanel implements ChartMouseListener, VEditor { public class VChart extends CPanel implements ChartMouseListener, VEditor {
/** /**
* *
*/ */
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 4089566607789995074L;
ChartPanel chartPanel; ChartPanel chartPanel;
MChart chartModel; MChart chartModel;
private ChartBuilder chartBuilder; private ChartBuilder chartBuilder;
@ -80,7 +80,7 @@ public class VChart extends CPanel implements ChartMouseListener, VEditor {
public void dispose() {} public void dispose() {}
@Override @Override
public String getName() {return chartModel.getName();} public String getName() {return chartModel.get_Translation(MChart.COLUMNNAME_Name);}
@Override @Override
public void removeVetoableChangeListener(VetoableChangeListener listener) {} public void removeVetoableChangeListener(VetoableChangeListener listener) {}

View File

@ -25,6 +25,7 @@ import java.awt.Insets;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
import java.awt.event.ActionListener; import java.awt.event.ActionListener;
import java.util.Properties; import java.util.Properties;
import java.util.UUID;
import java.util.logging.Level; import java.util.logging.Level;
import javax.swing.BorderFactory; import javax.swing.BorderFactory;
@ -494,9 +495,9 @@ public class ValuePreference extends CDialog
int AD_Preference_ID = DB.getNextID(m_ctx, "AD_Preference", null); int AD_Preference_ID = DB.getNextID(m_ctx, "AD_Preference", null);
// //
StringBuilder sql = new StringBuilder ("INSERT INTO AD_Preference (" StringBuilder sql = new StringBuilder ("INSERT INTO AD_Preference ("
+ "AD_Preference_ID, AD_Client_ID, AD_Org_ID, IsActive, Created,CreatedBy,Updated,UpdatedBy," + "AD_Preference_ID, AD_Preference_UU, AD_Client_ID, AD_Org_ID, IsActive, Created,CreatedBy,Updated,UpdatedBy,"
+ "AD_Window_ID, AD_User_ID, Attribute, Value) VALUES ("); + "AD_Window_ID, AD_User_ID, Attribute, Value) VALUES (");
sql.append(AD_Preference_ID).append(",").append(Client_ID).append(",").append(Org_ID) sql.append(AD_Preference_ID).append(",").append(DB.TO_STRING(UUID.randomUUID().toString())).append(",").append(Client_ID).append(",").append(Org_ID)
.append(", 'Y',SysDate,").append(m_AD_User_ID).append(",SysDate,").append(m_AD_User_ID).append(", "); .append(", 'Y',SysDate,").append(m_AD_User_ID).append(",SysDate,").append(m_AD_User_ID).append(", ");
if (cbWindow.isSelected()) if (cbWindow.isSelected())
sql.append(m_AD_Window_ID).append(","); sql.append(m_AD_Window_ID).append(",");

View File

@ -17,6 +17,7 @@
package org.adempiere.webui; package org.adempiere.webui;
import java.util.Properties; import java.util.Properties;
import java.util.UUID;
import java.util.logging.Level; import java.util.logging.Level;
import org.adempiere.webui.adwindow.ADWindow; import org.adempiere.webui.adwindow.ADWindow;
@ -65,7 +66,7 @@ public class ValuePreference extends Window implements EventListener<Event>
/** /**
* *
*/ */
private static final long serialVersionUID = -8490929927886340040L; private static final long serialVersionUID = 471820722501563271L;
/** /**
* Factory * Factory
@ -533,9 +534,9 @@ public class ValuePreference extends Window implements EventListener<Event>
int AD_Preference_ID = DB.getNextID(m_ctx, "AD_Preference", null); int AD_Preference_ID = DB.getNextID(m_ctx, "AD_Preference", null);
// //
StringBuilder sql = new StringBuilder ("INSERT INTO AD_Preference (" StringBuilder sql = new StringBuilder ("INSERT INTO AD_Preference ("
+ "AD_Preference_ID, AD_Client_ID, AD_Org_ID, IsActive, Created,CreatedBy,Updated,UpdatedBy," + "AD_Preference_ID, AD_Preference_UU, AD_Client_ID, AD_Org_ID, IsActive, Created,CreatedBy,Updated,UpdatedBy,"
+ "AD_Window_ID, AD_User_ID, Attribute, Value) VALUES ("); + "AD_Window_ID, AD_User_ID, Attribute, Value) VALUES (");
sql.append(AD_Preference_ID).append(",").append(Client_ID).append(",").append(Org_ID) sql.append(AD_Preference_ID).append(",").append(DB.TO_STRING(UUID.randomUUID().toString())).append(",").append(Client_ID).append(",").append(Org_ID)
.append(", 'Y',SysDate,").append(m_AD_User_ID).append(",SysDate,").append(m_AD_User_ID).append(", "); .append(", 'Y',SysDate,").append(m_AD_User_ID).append(",SysDate,").append(m_AD_User_ID).append(", ");
if (cbWindow.isChecked()) if (cbWindow.isChecked())
sql.append(m_AD_Window_ID).append(","); sql.append(m_AD_Window_ID).append(",");

View File

@ -505,7 +505,9 @@ public class ProcessModalDialog extends Window implements EventListener<Event>,
if (log.isLoggable(Level.INFO))log.log(Level.INFO, "Process Info="+m_pi+" AD_Client_ID="+Env.getAD_Client_ID(Env.getCtx())); if (log.isLoggable(Level.INFO))log.log(Level.INFO, "Process Info="+m_pi+" AD_Client_ID="+Env.getAD_Client_ID(Env.getCtx()));
WProcessCtl.process(ProcessModalDialog.this, m_WindowNo, parameterPanel, m_pi, null); WProcessCtl.process(ProcessModalDialog.this, m_WindowNo, parameterPanel, m_pi, null);
} catch (Exception ex) { } catch (Exception ex) {
FDialog.error(m_WindowNo, ex.getLocalizedMessage()); m_pi.setError(true);
m_pi.setSummary(ex.getLocalizedMessage());
log.log(Level.SEVERE, ex.getLocalizedMessage(), ex);
} finally { } finally {
Executions.schedule(getDesktop(), ProcessModalDialog.this, new Event(ON_COMPLETE, ProcessModalDialog.this, null)); Executions.schedule(getDesktop(), ProcessModalDialog.this, new Event(ON_COMPLETE, ProcessModalDialog.this, null));
} }

View File

@ -83,7 +83,7 @@ public class WChartEditor extends WEditor
@Override @Override
public String getDisplay() public String getDisplay()
{ {
return chartModel.getName(); return chartModel.get_Translation(MChart.COLUMNNAME_Name);
} }
@Override @Override

View File

@ -52,11 +52,11 @@ import org.zkoss.zul.South;
* *
*/ */
public class BroadcastMessageWindow extends Window implements IBroadcastMsgPopup,EventListener<Event>{ public class BroadcastMessageWindow extends Window implements IBroadcastMsgPopup,EventListener<Event>{
/** /**
* *
*/ */
private static final long serialVersionUID = 5990080817061314383L; private static final long serialVersionUID = 1849434312706721390L;
private static CLogger log = CLogger.getCLogger(BroadcastMessageWindow.class); private static CLogger log = CLogger.getCLogger(BroadcastMessageWindow.class);
public static final int PRESSED_PREV = 1; public static final int PRESSED_PREV = 1;
public static final int PRESSED_NEXT = 2; public static final int PRESSED_NEXT = 2;
@ -112,7 +112,7 @@ public class BroadcastMessageWindow extends Window implements IBroadcastMsgPopup
Div htmlDiv = new Div(); Div htmlDiv = new Div();
//textMsgContent = new Label(); //textMsgContent = new Label();
htmlDiv.appendChild(textMsgContent); htmlDiv.appendChild(textMsgContent);
textMsgContent.setContent(mbMessages.get(0).getBroadcastMessage()); textMsgContent.setContent(mbMessages.get(0).get_Translation(MBroadcastMessage.COLUMNNAME_BroadcastMessage));
htmlDiv.setFocus(true); htmlDiv.setFocus(true);
htmlDiv.setStyle("display: table-cell; vertical-align: middle; text-align: center;"); htmlDiv.setStyle("display: table-cell; vertical-align: middle; text-align: center;");
Div divAlign = new Div(); Div divAlign = new Div();
@ -292,7 +292,7 @@ public class BroadcastMessageWindow extends Window implements IBroadcastMsgPopup
} }
textMsgNo.setValue((currMsg+1)+"/"+noOfMsgs); textMsgNo.setValue((currMsg+1)+"/"+noOfMsgs);
textMsgContent.setContent(mbMessage.getBroadcastMessage()); textMsgContent.setContent(mbMessage.get_Translation(MBroadcastMessage.COLUMNNAME_BroadcastMessage));
if (!isTest && mbMessage.isLogAcknowledge()) { if (!isTest && mbMessage.isLogAcknowledge()) {
boolean ack = hashMessages.get(mbMessage.get_ID()); boolean ack = hashMessages.get(mbMessage.get_ID());

View File

@ -190,6 +190,8 @@ public class LoginPanel extends Window implements EventListener<Event>
}); });
// Make the default language the language of client System // Make the default language the language of client System
// TODO: possible improvement to check if the first default browser language is supported and default to it
// Executions.getCurrent().getHeader("accept-language");
String defaultLanguage = MClient.get(ctx, 0).getAD_Language(); String defaultLanguage = MClient.get(ctx, 0).getAD_Language();
for(int i = 0; i < lstLanguage.getItemCount(); i++) for(int i = 0; i < lstLanguage.getItemCount(); i++)
{ {
@ -414,6 +416,7 @@ public class LoginPanel extends Window implements EventListener<Event>
{ {
btnResetPasswordClicked(); btnResetPasswordClicked();
} }
/* code below commented per security issue IDEMPIERE-1797 reported
// Elaine 2009/02/06 - initial language // Elaine 2009/02/06 - initial language
else if (event.getName().equals(Events.ON_CHANGE)) else if (event.getName().equals(Events.ON_CHANGE))
{ {
@ -422,6 +425,7 @@ public class LoginPanel extends Window implements EventListener<Event>
onUserIdChange(-1); onUserIdChange(-1);
} }
} }
*/
else if (event.getName().equals(ON_LOAD_TOKEN)) else if (event.getName().equals(ON_LOAD_TOKEN))
{ {
BrowserToken.load(txtUserId); BrowserToken.load(txtUserId);

View File

@ -506,6 +506,7 @@ public class ResetPasswordPanel extends Window implements EventListener<Event>
return false; return false;
MMailText mailText = new MMailText(m_ctx, R_MailText_ID, null); MMailText mailText = new MMailText(m_ctx, R_MailText_ID, null);
mailText.setLanguage(Env.getContext(m_ctx, "#AD_Language"));
to.set_ValueOfColumn("Password", newPassword); // will be hashed and validate on saveEx to.set_ValueOfColumn("Password", newPassword); // will be hashed and validate on saveEx
mailText.setUser(to); mailText.setUser(to);
String message = mailText.getMailText(true); String message = mailText.getMailText(true);

View File

@ -55,8 +55,8 @@ public class FactReconcile {
Vector<String> columnNames = new Vector<String>(); Vector<String> columnNames = new Vector<String>();
columnNames.add(Msg.translate(Env.getCtx(), "Amt")); columnNames.add(Msg.translate(Env.getCtx(), "Amt"));
//columnNames.add(Msg.translate(Env.getCtx(), "AmtAcct")); //columnNames.add(Msg.translate(Env.getCtx(), "AmtAcct"));
columnNames.add("DR/CR"); columnNames.add(Msg.translate(Env.getCtx(), "DR/CR"));
columnNames.add("Fact Acct"); columnNames.add(Msg.translate(Env.getCtx(), "Selected"));
columnNames.add(Msg.translate(Env.getCtx(), "C_BPartner_ID")); columnNames.add(Msg.translate(Env.getCtx(), "C_BPartner_ID"));
columnNames.add(Msg.translate(Env.getCtx(), "DateAcct")); columnNames.add(Msg.translate(Env.getCtx(), "DateAcct"));
columnNames.add(Msg.translate(Env.getCtx(), "GL_Category_ID")); columnNames.add(Msg.translate(Env.getCtx(), "GL_Category_ID"));
@ -74,16 +74,20 @@ public class FactReconcile {
Vector<Vector<Object>> data = new Vector<Vector<Object>>(); Vector<Vector<Object>> data = new Vector<Vector<Object>>();
StringBuilder sql = new StringBuilder("SELECT abs(fa.amtacctdr-fa.amtacctcr), (fa.amtacctdr-fa.amtacctcr)," // 1-2 StringBuilder sql = new StringBuilder("SELECT abs(fa.amtacctdr-fa.amtacctcr), (fa.amtacctdr-fa.amtacctcr),") // 1-2
+ " (CASE WHEN (fa.amtacctdr-fa.amtacctcr) < 0 THEN 'CR' ELSE 'DR' END), fa.Fact_Acct_ID, bp.name, DateAcct," .append(" (CASE WHEN (fa.amtacctdr-fa.amtacctcr) < 0 THEN ")
+ " glc.name, p.name, Qty, fa.Description, r.MatchCode, fa.DateTrx, o.value" .append(DB.TO_STRING(Msg.translate(Env.getCtx(), "CR")))
+ " FROM Fact_Acct fa" .append(" ELSE ")
+ " LEFT OUTER JOIN Fact_Reconciliation r ON (fa.Fact_Acct_ID=r.Fact_Acct_ID)" .append(DB.TO_STRING(Msg.translate(Env.getCtx(), "DR")))
+ " LEFT OUTER JOIN C_BPartner bp ON (fa.C_BPartner_ID=bp.C_BPartner_ID)" .append(" END), fa.Fact_Acct_ID, bp.name, DateAcct,")
+ " LEFT OUTER JOIN AD_Org o ON (o.AD_Org_ID=fa.AD_Org_ID)" .append(" glc.name, p.name, Qty, fa.Description, r.MatchCode, fa.DateTrx, o.value")
+ " LEFT OUTER JOIN M_Product p ON (p.M_Product_ID=fa.M_Product_ID)" .append(" FROM Fact_Acct fa")
+ " LEFT OUTER JOIN GL_Category glc ON (fa.GL_Category_ID=glc.GL_Category_ID)" .append(" LEFT OUTER JOIN Fact_Reconciliation r ON (fa.Fact_Acct_ID=r.Fact_Acct_ID)")
+ " WHERE fa.AD_Client_ID=?"); .append(" LEFT OUTER JOIN C_BPartner bp ON (fa.C_BPartner_ID=bp.C_BPartner_ID)")
.append(" LEFT OUTER JOIN AD_Org o ON (o.AD_Org_ID=fa.AD_Org_ID)")
.append(" LEFT OUTER JOIN M_Product p ON (p.M_Product_ID=fa.M_Product_ID)")
.append(" LEFT OUTER JOIN GL_Category glc ON (fa.GL_Category_ID=glc.GL_Category_ID)")
.append(" WHERE fa.AD_Client_ID=?");
// role security // role security
sql = new StringBuilder( MRole.getDefault(Env.getCtx(), false).addAccessSQL( sql.toString(), "fa", MRole.SQL_FULLYQUALIFIED, MRole.SQL_RO ) ); sql = new StringBuilder( MRole.getDefault(Env.getCtx(), false).addAccessSQL( sql.toString(), "fa", MRole.SQL_FULLYQUALIFIED, MRole.SQL_RO ) );

View File

@ -20,6 +20,11 @@
<arguments> <arguments>
</arguments> </arguments>
</buildCommand> </buildCommand>
<buildCommand>
<name>org.eclipse.pde.ds.core.builder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec> </buildSpec>
<natures> <natures>
<nature>org.eclipse.pde.PluginNature</nature> <nature>org.eclipse.pde.PluginNature</nature>

View File

@ -5,6 +5,7 @@ Bundle-SymbolicName: org.idempiere.webservices;singleton:=true
Bundle-Version: 2.0.0.qualifier Bundle-Version: 2.0.0.qualifier
Bundle-Activator: org.idempiere.webservices.Activator Bundle-Activator: org.idempiere.webservices.Activator
Bundle-RequiredExecutionEnvironment: JavaSE-1.6 Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Service-Component: OSGI-INF/ws_modelfactory.xml
Import-Package: javax.activation;version="1.1.1", Import-Package: javax.activation;version="1.1.1",
javax.mail.internet;version="1.5", javax.mail.internet;version="1.5",
javax.servlet;version="3.0.0", javax.servlet;version="3.0.0",

View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" name="org.compiere.model.WS_ModelFactory">
<implementation class="org.compiere.model.WS_ModelFactory"/>
<property name="service.ranking" type="Integer" value="5"/>
<service>
<provide interface="org.adempiere.base.IModelFactory"/>
</service>
</scr:component>

View File

@ -0,0 +1,85 @@
/***********************************************************************
* This file is part of iDempiere ERP Bazaar *
* http://www.idempiere.org *
* *
* Copyright (C) Carlos Ruiz - globalqss *
* Copyright (C) Contributors *
* *
* 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. *
* *
* Contributors: *
* - Carlos Ruiz (globalqss@users.sourceforge.net) *
* *
* Sponsors: *
* - GlobalQSS (http://www.globalqss.com) *
***********************************************************************/
package org.compiere.model;
import java.sql.ResultSet;
import java.util.Properties;
/**
* Web Services Parameters Model
*
* @author Carlos Ruiz
*/
public class MWebServicePara extends X_WS_WebService_Para
{
/**
*
*/
private static final long serialVersionUID = 3561409141850981248L;
/**************************************************************************
* Standard Constructor
* @param ctx context
* @param WS_WebService_Para_ID
* @param trxName transaction
*/
public MWebServicePara (Properties ctx, int WS_WebService_Para_ID, String trxName)
{
super (ctx, WS_WebService_Para_ID, trxName);
/** if (WS_WebService_Para_ID == 0)
{
setName (null);
setValue (null);
WS_WebService_Para_ID (0);
} */
} // MWebServicePara
/**
* Load Constructor
* @param ctx context
* @param rs result set
* @param trxName transaction
*/
public MWebServicePara (Properties ctx, ResultSet rs, String trxName)
{
super(ctx, rs, trxName);
} // MWebServicePara
@Override
protected boolean beforeSave(boolean newRecord) {
if ( "Filter".equalsIgnoreCase(getParameterName())
&& PARAMETERTYPE_Free.equals(getParameterType())) {
log.saveError("Error", "Type Free not allowed for parameter Filter (security issue)"); // IDEMPIERE-1784
return false;
}
return true;
}
} // MWebServicePara

View File

@ -0,0 +1,69 @@
/**********************************************************************
* This file is part of iDempiere ERP Open Source *
* http://www.idempiere.org *
* *
* Copyright (C) Contributors *
* *
* 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. *
* *
* Contributors: *
* - Carlos Ruiz - globalqss *
**********************************************************************/
package org.compiere.model;
import java.sql.ResultSet;
import org.adempiere.base.IModelFactory;
import org.compiere.model.PO;
import org.compiere.util.Env;
public class WS_ModelFactory implements IModelFactory {
@Override
public Class<?> getClass(String tableName) {
if (X_WS_WebService_Para.Table_Name.equals(tableName))
return MWebServicePara.class;
if (X_WS_WebServiceType.Table_Name.equals(tableName))
return MWebServiceType.class;
if (X_WS_WebService.Table_Name.equals(tableName))
return MWebService.class;
return null;
}
@Override
public PO getPO(String tableName, int Record_ID, String trxName) {
if (X_WS_WebService_Para.Table_Name.equals(tableName))
return new MWebServicePara(Env.getCtx(), Record_ID, trxName);
if (X_WS_WebServiceType.Table_Name.equals(tableName))
return new MWebServiceType(Env.getCtx(), Record_ID, trxName);
if (X_WS_WebService.Table_Name.equals(tableName))
return new MWebService(Env.getCtx(), Record_ID, trxName);
return null;
}
@Override
public PO getPO(String tableName, ResultSet rs, String trxName) {
if (X_WS_WebService_Para.Table_Name.equals(tableName))
return new MWebServicePara(Env.getCtx(), rs, trxName);
if (X_WS_WebServiceType.Table_Name.equals(tableName))
return new MWebServiceType(Env.getCtx(), rs, trxName);
if (X_WS_WebService.Table_Name.equals(tableName))
return new MWebService(Env.getCtx(), rs, trxName);
return null;
}
}