Changed to comply with adempiere/migration/330-trunk/postgresql/028_FR_1799601_PG.sql

This commit is contained in:
wght 2007-12-05 22:38:14 +00:00
parent 273a0dcaf0
commit 60904e151d
2 changed files with 23 additions and 22 deletions

View File

@ -11,11 +11,11 @@ SELECT il.AD_Client_ID, il.AD_Org_ID,
i.C_BPartner_ID, il.M_Product_ID,
i.DocumentNo, i.DateInvoiced, i.DateAcct,
i.IsSOTrx, i.DocStatus,
ROUND(i.Multiplier*LineNetAmt, 2) AS LineNetAmt,
ROUND(i.Multiplier*PriceList*QtyInvoiced, 2) 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,
ROUND(i.Multiplier*PriceList*QtyInvoiced-LineNetAmt,2) AS LineDiscountAmt,
CASE WHEN COALESCE(il.PriceLimit,0)=0 THEN 0 ELSE ROUND(i.Multiplier*LineNetAmt-PriceLimit*QtyInvoiced,2) END AS LineOverLimitAmt,
ROUND(i.Multiplier*il.LineNetAmt, 2) AS LineNetAmt,
ROUND(i.Multiplier*il.PriceList*il.QtyInvoiced, 2) AS LineListAmt,
CASE WHEN COALESCE(il.PriceLimit, 0::numeric)=0::numeric 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::numeric)=0::numeric THEN 0::numeric ELSE ROUND(i.Multiplier*il.LineNetAmt-il.PriceLimit*il.QtyInvoiced,2) END AS LineOverLimitAmt,
il.QtyInvoiced, il.QtyEntered,
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

View File

@ -7,7 +7,7 @@ CREATE OR REPLACE VIEW C_INVOICE_V
C_BPARTNER_LOCATION_ID, AD_USER_ID, POREFERENCE, DATEORDERED, C_CURRENCY_ID,
C_CONVERSIONTYPE_ID, PAYMENTRULE, C_PAYMENTTERM_ID, C_CHARGE_ID, M_PRICELIST_ID,
C_CAMPAIGN_ID, C_PROJECT_ID, C_ACTIVITY_ID, ISPRINTED, ISDISCOUNTPRINTED,
ISPAID, ISINDISPUTE, ISPAYSCHEDULEVALID, C_INVOICEPAYSCHEDULE_ID, INVOICECOLLECTIONTYPE,
ISPAID, ISINDISPUTE, ISPAYSCHEDULEVALID, C_INVOICEPAYSCHEDULE_ID, INVOICECOLLECTIONTYPE, DUNNINGGRACE,
CHARGEAMT, TOTALLINES, GRANDTOTAL, MULTIPLIER, MULTIPLIERAP,
DOCBASETYPE)
AS
@ -18,16 +18,16 @@ SELECT i.C_Invoice_ID, i.AD_Client_ID, i.AD_Org_ID, i.IsActive, i.Created, i.Cre
i.AD_User_ID, i.POReference, i.DateOrdered, i.C_Currency_ID, i.C_ConversionType_ID, i.PaymentRule,
i.C_PaymentTerm_ID, i.C_Charge_ID, i.M_PriceList_ID, i.C_Campaign_ID, i.C_Project_ID,
i.C_Activity_ID, i.IsPrinted, i.IsDiscountPrinted, i.IsPaid, i.IsInDispute,
i.IsPayScheduleValid, cast(null as numeric) AS C_InvoicePaySchedule_ID, i.InvoiceCollectionType,
cast(CASE WHEN charAt(d.DocBaseType,3)='C' THEN i.ChargeAmt*-1 ELSE i.ChargeAmt END as numeric) AS ChargeAmt,
cast(CASE WHEN charAt(d.DocBaseType,3)='C' THEN i.TotalLines*-1 ELSE i.TotalLines END as numeric) AS TotalLines,
cast(CASE WHEN charAt(d.DocBaseType,3)='C' THEN i.GrandTotal*-1 ELSE i.GrandTotal END as numeric) AS GrandTotal,
cast(CASE WHEN charAt(d.DocBaseType,3)='C' THEN -1 ELSE 1 END as numeric) AS Multiplier,
cast(CASE WHEN charAt(d.DocBaseType,2)='P' THEN -1 ELSE 1 END AS numeric) as MultiplierAP,
i.IsPayScheduleValid, NULL::numeric) AS C_InvoicePaySchedule_ID, i.InvoiceCollectionType, i.dunninggrace,
CASE WHEN charAt(d.DocBaseType::character varying, 3)::text ='C'::text THEN i.ChargeAmt*-1::numeric ELSE i.ChargeAmt END AS ChargeAmt,
CASE WHEN charAt(d.DocBaseType::character varying,3)::text='C'::text THEN i.TotalLines*-1::numeric ELSE i.TotalLines END AS TotalLines,
CASE WHEN charAt(d.DocBaseType::character varying,3)::text ='C'::text THEN i.GrandTotal*-1::numeric ELSE i.GrandTotal END AS GrandTotal,
CASE WHEN charAt(d.DocBaseType::character varying,3)::text ='C'::text THEN -1 ELSE 1 END::numeric AS Multiplier,
CASE WHEN charAt(d.DocBaseType::character varying,2)::text ='P':;text THEN -1 ELSE 1 END::numeric AS MultiplierAP,
d.DocBaseType
FROM C_Invoice i
INNER JOIN C_DocType d ON (i.C_DocType_ID=d.C_DocType_ID)
WHERE i.IsPayScheduleValid<>'Y'
WHERE i.IsPayScheduleValid<>'Y'::bpchar
UNION
SELECT i.C_Invoice_ID, i.AD_Client_ID, i.AD_Org_ID, i.IsActive, i.Created, i.CreatedBy, i.Updated, i.UpdatedBy,
i.IsSOTrx, i.DocumentNo, i.DocStatus, i.DocAction, i.Processing, i.Processed, i.C_DocType_ID,
@ -37,17 +37,18 @@ SELECT i.C_Invoice_ID, i.AD_Client_ID, i.AD_Org_ID, i.IsActive, i.Created, i.Cre
i.C_PaymentTerm_ID, i.C_Charge_ID, i.M_PriceList_ID, i.C_Campaign_ID, i.C_Project_ID,
i.C_Activity_ID, i.IsPrinted, i.IsDiscountPrinted, i.IsPaid, i.IsInDispute,
i.IsPayScheduleValid, ips.C_InvoicePaySchedule_ID, i.InvoiceCollectionType,
null AS ChargeAmt,
null AS TotalLines,
CASE WHEN charAt(d.DocBaseType,3)='C' THEN ips.DueAmt*-1 ELSE ips.DueAmt END AS GrandTotal,
CASE WHEN charAt(d.DocBaseType,3)='C' THEN -1 ELSE 1 END AS Multiplier,
CASE WHEN charAt(d.DocBaseType,2)='P' THEN -1 ELSE 1 END AS MultiplierAP,
i.dunninggrace,
NULL::"unknown" AS ChargeAmt,
NULL::"unknown" AS TotalLines,
CASE WHEN charAt(d.DocBaseType::character varying,3)::text ='C'::text THEN ips.DueAmt*-1::numeric ELSE ips.DueAmt END AS GrandTotal,
CASE WHEN charAt(d.DocBaseType::character varying,3)::text ='C'::text THEN -1 ELSE 1 END AS Multiplier,
CASE WHEN charAt(d.DocBaseType::character varying,2)::text ='P'::text THEN -1 ELSE 1 END AS MultiplierAP,
d.DocBaseType
FROM C_Invoice i
INNER JOIN C_DocType d ON (i.C_DocType_ID=d.C_DocType_ID)
INNER JOIN C_InvoicePaySchedule ips ON (i.C_Invoice_ID=ips.C_Invoice_ID)
WHERE i.IsPayScheduleValid='Y'
AND ips.IsValid='Y';
JOIN C_DocType d ON (i.C_DocType_ID=d.C_DocType_ID)
JOIN C_InvoicePaySchedule ips ON (i.C_Invoice_ID=ips.C_Invoice_ID)
WHERE i.IsPayScheduleValid='Y'::bpchar
AND ips.IsValid='Y'::bpchar;