From a3e89f32f88e3a45b88a9ed5b339a9c666dc4b27 Mon Sep 17 00:00:00 2001 From: vpj-cd Date: Tue, 2 Sep 2008 01:08:42 +0000 Subject: [PATCH] http://sourceforge.net/tracker/index.php?func=detail&aid=1926882&group_id=176962&atid=879335 discusion https://sourceforge.net/forum/message.php?msg_id=5216017 --- db/ddlutils/oracle/views/C_INVOICE_V.sql | 10 ++-- db/ddlutils/postgresql/views/C_INVOICE_V.sql | 10 ++-- .../280_FB_1926882_Fix_C_Invoice_v.sql | 57 +++++++++++++++++++ .../280_FB_1926882_Fix_C_Invoice_v.sql | 54 ++++++++++++++++++ 4 files changed, 121 insertions(+), 10 deletions(-) create mode 100644 migration/352a-trunk/280_FB_1926882_Fix_C_Invoice_v.sql create mode 100644 migration/352a-trunk/postgresql/280_FB_1926882_Fix_C_Invoice_v.sql diff --git a/db/ddlutils/oracle/views/C_INVOICE_V.sql b/db/ddlutils/oracle/views/C_INVOICE_V.sql index 206ebc8aba..6aa4ebef13 100644 --- a/db/ddlutils/oracle/views/C_INVOICE_V.sql +++ b/db/ddlutils/oracle/views/C_INVOICE_V.sql @@ -20,11 +20,11 @@ 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, cast(null as number) AS C_InvoicePaySchedule_ID, i.InvoiceCollectionType, - cast(CASE WHEN charAt(d.DocBaseType,3)='C' THEN i.ChargeAmt*-1 ELSE i.ChargeAmt END as number) AS ChargeAmt, - cast(CASE WHEN charAt(d.DocBaseType,3)='C' THEN i.TotalLines*-1 ELSE i.TotalLines END as number) AS TotalLines, - cast(CASE WHEN charAt(d.DocBaseType,3)='C' THEN i.GrandTotal*-1 ELSE i.GrandTotal END as number) AS GrandTotal, - cast(CASE WHEN charAt(d.DocBaseType,3)='C' THEN -1 ELSE 1 END as number) AS Multiplier, - cast(CASE WHEN charAt(d.DocBaseType,2)='P' THEN -1 ELSE 1 END AS number) as MultiplierAP, + CASE WHEN charAt(d.DocBaseType,3)='C' THEN i.ChargeAmt*-1 ELSE i.ChargeAmt END AS ChargeAmt, + CASE WHEN charAt(d.DocBaseType,3)='C' THEN i.TotalLines*-1 ELSE i.TotalLines END AS TotalLines, + CASE WHEN charAt(d.DocBaseType,3)='C' THEN i.GrandTotal*-1 ELSE i.GrandTotal END AS GrandTotal, + CASE WHEN charAt(d.DocBaseType,3)='C' THEN -1 ELSE 1 END as number) AS Multiplier, + CASE WHEN charAt(d.DocBaseType,2)='P' THEN -1 ELSE 1 END AS number) as MultiplierAP, d.DocBaseType , paymentTermDueDate(i.C_PaymentTerm_ID, i.DateInvoiced) as DueDate FROM C_Invoice i diff --git a/db/ddlutils/postgresql/views/C_INVOICE_V.sql b/db/ddlutils/postgresql/views/C_INVOICE_V.sql index ba4381567a..7abfcdd1e0 100644 --- a/db/ddlutils/postgresql/views/C_INVOICE_V.sql +++ b/db/ddlutils/postgresql/views/C_INVOICE_V.sql @@ -20,11 +20,11 @@ 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, cast(null as numeric) AS C_InvoicePaySchedule_ID, i.InvoiceCollectionType,i.DunningGrace, - 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, + CASE WHEN charAt(d.DocBaseType,3)='C' THEN i.ChargeAmt*-1 ELSE i.ChargeAmt END AS ChargeAmt, + CASE WHEN charAt(d.DocBaseType,3)='C' THEN i.TotalLines*-1 ELSE i.TotalLines END AS TotalLines, + CASE WHEN charAt(d.DocBaseType,3)='C' THEN i.GrandTotal*-1 ELSE i.GrandTotal 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, d.DocBaseType , paymentTermDueDate(i.C_PaymentTerm_ID, i.DateInvoiced) as DueDate FROM C_Invoice i diff --git a/migration/352a-trunk/280_FB_1926882_Fix_C_Invoice_v.sql b/migration/352a-trunk/280_FB_1926882_Fix_C_Invoice_v.sql new file mode 100644 index 0000000000..29b8262ef9 --- /dev/null +++ b/migration/352a-trunk/280_FB_1926882_Fix_C_Invoice_v.sql @@ -0,0 +1,57 @@ +DROP VIEW C_INVOICE_V; +CREATE OR REPLACE VIEW C_INVOICE_V +(C_INVOICE_ID, AD_CLIENT_ID, AD_ORG_ID, ISACTIVE, CREATED, + CREATEDBY, UPDATED, UPDATEDBY, ISSOTRX, DOCUMENTNO, + DOCSTATUS, DOCACTION, PROCESSING, PROCESSED, C_DOCTYPE_ID, + C_DOCTYPETARGET_ID, C_ORDER_ID, DESCRIPTION, ISAPPROVED, ISTRANSFERRED, + SALESREP_ID, DATEINVOICED, DATEPRINTED, DATEACCT, C_BPARTNER_ID, + 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, + CHARGEAMT, TOTALLINES, GRANDTOTAL, MULTIPLIER, MULTIPLIERAP, + DOCBASETYPE, DUEDATE + ) +AS +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, + i.C_DocTypeTarget_ID, i.C_Order_ID, i.Description, i.IsApproved, i.IsTransferred, + i.SalesRep_ID, i.DateInvoiced, i.DatePrinted, i.DateAcct, i.C_BPartner_ID, i.C_BPartner_Location_ID, + 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 number) AS C_InvoicePaySchedule_ID, i.InvoiceCollectionType, + CASE WHEN charAt(d.DocBaseType,3)='C' THEN i.ChargeAmt*-1 ELSE i.ChargeAmt END AS ChargeAmt, + CASE WHEN charAt(d.DocBaseType,3)='C' THEN i.TotalLines*-1 ELSE i.TotalLines END AS TotalLines, + CASE WHEN charAt(d.DocBaseType,3)='C' THEN i.GrandTotal*-1 ELSE i.GrandTotal END AS GrandTotal, + CASE WHEN charAt(d.DocBaseType,3)='C' THEN -1 ELSE 1 END as number) AS Multiplier, + CASE WHEN charAt(d.DocBaseType,2)='P' THEN -1 ELSE 1 END AS number) as MultiplierAP, + d.DocBaseType + , paymentTermDueDate(i.C_PaymentTerm_ID, i.DateInvoiced) as DueDate +FROM C_Invoice i + INNER JOIN C_DocType d ON (i.C_DocType_ID=d.C_DocType_ID) +WHERE i.IsPayScheduleValid<>'Y' +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, + i.C_DocTypeTarget_ID, i.C_Order_ID, i.Description, i.IsApproved, i.IsTransferred, + i.SalesRep_ID, i.DateInvoiced, i.DatePrinted, i.DateAcct, i.C_BPartner_ID, i.C_BPartner_Location_ID, + 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, 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, + d.DocBaseType + , ips.DueDate +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'; + + + diff --git a/migration/352a-trunk/postgresql/280_FB_1926882_Fix_C_Invoice_v.sql b/migration/352a-trunk/postgresql/280_FB_1926882_Fix_C_Invoice_v.sql new file mode 100644 index 0000000000..c13132e679 --- /dev/null +++ b/migration/352a-trunk/postgresql/280_FB_1926882_Fix_C_Invoice_v.sql @@ -0,0 +1,54 @@ +DROP VIEW C_INVOICE_V; +CREATE OR REPLACE VIEW C_INVOICE_V +(C_INVOICE_ID, AD_CLIENT_ID, AD_ORG_ID, ISACTIVE, CREATED, + CREATEDBY, UPDATED, UPDATEDBY, ISSOTRX, DOCUMENTNO, + DOCSTATUS, DOCACTION, PROCESSING, PROCESSED, C_DOCTYPE_ID, + C_DOCTYPETARGET_ID, C_ORDER_ID, DESCRIPTION, ISAPPROVED, ISTRANSFERRED, + SALESREP_ID, DATEINVOICED, DATEPRINTED, DATEACCT, C_BPARTNER_ID, + 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,DUNNINGGRACE, + CHARGEAMT, TOTALLINES, GRANDTOTAL, MULTIPLIER, MULTIPLIERAP, + DOCBASETYPE, DUEDATE + ) +AS +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, + i.C_DocTypeTarget_ID, i.C_Order_ID, i.Description, i.IsApproved, i.IsTransferred, + i.SalesRep_ID, i.DateInvoiced, i.DatePrinted, i.DateAcct, i.C_BPartner_ID, i.C_BPartner_Location_ID, + 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,i.DunningGrace, + CASE WHEN charAt(d.DocBaseType,3)='C' THEN i.ChargeAmt*-1 ELSE i.ChargeAmt END AS ChargeAmt, + CASE WHEN charAt(d.DocBaseType,3)='C' THEN i.TotalLines*-1 ELSE i.TotalLines END AS TotalLines, + CASE WHEN charAt(d.DocBaseType,3)='C' THEN i.GrandTotal*-1 ELSE i.GrandTotal 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, + d.DocBaseType + , paymentTermDueDate(i.C_PaymentTerm_ID, i.DateInvoiced) as DueDate +FROM C_Invoice i + INNER JOIN C_DocType d ON (i.C_DocType_ID=d.C_DocType_ID) +WHERE i.IsPayScheduleValid<>'Y' +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, + i.C_DocTypeTarget_ID, i.C_Order_ID, i.Description, i.IsApproved, i.IsTransferred, + i.SalesRep_ID, i.DateInvoiced, i.DatePrinted, i.DateAcct, i.C_BPartner_ID, i.C_BPartner_Location_ID, + 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, ips.C_InvoicePaySchedule_ID, i.InvoiceCollectionType, i.DunningGrace, + 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, + d.DocBaseType + , ips.DueDate +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'; \ No newline at end of file