diff --git a/db/ddlutils/oracle/views/RV_OPENITEM.sql b/db/ddlutils/oracle/views/RV_OPENITEM.sql index 337e1da732..8f625d3a9a 100644 --- a/db/ddlutils/oracle/views/RV_OPENITEM.sql +++ b/db/ddlutils/oracle/views/RV_OPENITEM.sql @@ -26,7 +26,7 @@ FROM RV_C_Invoice i WHERE -- i.IsPaid='N' invoiceOpen(i.C_Invoice_ID,0) <> 0 AND i.IsPayScheduleValid<>'Y' - AND i.DocStatus<>'DR' + AND i.DocStatus IN ('CO','CL') UNION SELECT i.AD_Org_ID, i.AD_Client_ID, i.DocumentNo, i.C_Invoice_ID, i.C_Order_ID, i.C_BPartner_ID, i.IsSOTrx, @@ -48,7 +48,7 @@ FROM RV_C_Invoice i WHERE -- i.IsPaid='N' invoiceOpen(i.C_Invoice_ID,ips.C_InvoicePaySchedule_ID) <> 0 AND i.IsPayScheduleValid='Y' - AND i.DocStatus<>'DR' + AND i.DocStatus IN ('CO','CL') AND ips.IsValid='Y'; diff --git a/db/ddlutils/oracle/views/RV_OPENITEMTODATE.sql b/db/ddlutils/oracle/views/RV_OPENITEMTODATE.sql index 2d543a8be1..7bfc6bf36d 100644 --- a/db/ddlutils/oracle/views/RV_OPENITEMTODATE.sql +++ b/db/ddlutils/oracle/views/RV_OPENITEMTODATE.sql @@ -28,6 +28,7 @@ WHERE -- i.IsPaid='N' --invoiceOpen(i.C_Invoice_ID,0) <> 0 AND i.IsPayScheduleValid<>'Y' AND i.DocStatus<>'DR' + AND i.DocStatus IN ('CO','CL') UNION SELECT i.AD_Org_ID, i.AD_Client_ID, i.DocumentNo, i.C_Invoice_ID, i.C_Order_ID, i.C_BPartner_ID, i.IsSOTrx, @@ -50,6 +51,7 @@ WHERE -- i.IsPaid='N' --invoiceOpen(i.C_Invoice_ID,ips.C_InvoicePaySchedule_ID) <> 0 AND i.IsPayScheduleValid='Y' AND i.DocStatus<>'DR' + AND i.DocStatus IN ('CO','CL') AND ips.IsValid='Y'; diff --git a/db/ddlutils/postgresql/views/RV_OPENITEM.sql b/db/ddlutils/postgresql/views/RV_OPENITEM.sql index 395d897919..9bdb8462f4 100644 --- a/db/ddlutils/postgresql/views/RV_OPENITEM.sql +++ b/db/ddlutils/postgresql/views/RV_OPENITEM.sql @@ -27,7 +27,7 @@ FROM RV_C_Invoice i WHERE -- i.IsPaid='N' invoiceOpen(i.C_Invoice_ID,0) <> 0 AND i.IsPayScheduleValid<>'Y' - AND i.DocStatus<>'DR' + AND i.DocStatus IN ('CO','CL') UNION SELECT i.AD_Org_ID, i.AD_Client_ID, i.DocumentNo, i.C_Invoice_ID, i.C_Order_ID, i.C_BPartner_ID, i.IsSOTrx, @@ -49,7 +49,7 @@ FROM RV_C_Invoice i WHERE -- i.IsPaid='N' invoiceOpen(i.C_Invoice_ID,ips.C_InvoicePaySchedule_ID) <> 0 AND i.IsPayScheduleValid='Y' - AND i.DocStatus<>'DR' + AND i.DocStatus IN ('CO','CL') AND ips.IsValid='Y'; diff --git a/db/ddlutils/postgresql/views/RV_OPENITEMTODATE.sql b/db/ddlutils/postgresql/views/RV_OPENITEMTODATE.sql index 9f6210e819..fdfedb99fb 100644 --- a/db/ddlutils/postgresql/views/RV_OPENITEMTODATE.sql +++ b/db/ddlutils/postgresql/views/RV_OPENITEMTODATE.sql @@ -27,7 +27,7 @@ FROM RV_C_Invoice i WHERE -- i.IsPaid='N' --invoiceOpen(i.C_Invoice_ID,0) <> 0 AND i.IsPayScheduleValid<>'Y' - AND i.DocStatus<>'DR' + AND i.DocStatus IN ('CO','CL') UNION SELECT i.AD_Org_ID, i.AD_Client_ID, i.DocumentNo, i.C_Invoice_ID, i.C_Order_ID, i.C_BPartner_ID, i.IsSOTrx, @@ -49,7 +49,7 @@ FROM RV_C_Invoice i WHERE -- i.IsPaid='N' --invoiceOpen(i.C_Invoice_ID,ips.C_InvoicePaySchedule_ID) <> 0 AND i.IsPayScheduleValid='Y' - AND i.DocStatus<>'DR' + AND i.DocStatus IN ('CO','CL') AND ips.IsValid='Y'; diff --git a/migration/353a-trunk/oracle/419_BF2563594.sql b/migration/353a-trunk/oracle/419_BF2563594.sql new file mode 100644 index 0000000000..f811da1815 --- /dev/null +++ b/migration/353a-trunk/oracle/419_BF2563594.sql @@ -0,0 +1,113 @@ +CREATE OR REPLACE VIEW RV_OPENITEM +(AD_ORG_ID, AD_CLIENT_ID, DOCUMENTNO, C_INVOICE_ID, C_ORDER_ID, + C_BPARTNER_ID, ISSOTRX, DATEINVOICED, DATEACCT, NETDAYS, + DUEDATE, DAYSDUE, DISCOUNTDATE, DISCOUNTAMT, GRANDTOTAL, + PAIDAMT, OPENAMT, C_CURRENCY_ID, C_CONVERSIONTYPE_ID, C_PAYMENTTERM_ID, + ISPAYSCHEDULEVALID, C_INVOICEPAYSCHEDULE_ID, INVOICECOLLECTIONTYPE, C_CAMPAIGN_ID, C_PROJECT_ID, + C_ACTIVITY_ID) +AS +SELECT i.AD_Org_ID, i.AD_Client_ID, + i.DocumentNo, i.C_Invoice_ID, i.C_Order_ID, i.C_BPartner_ID, i.IsSOTrx, + i.DateInvoiced, i.DateAcct, + p.NetDays, + paymentTermDueDate(i.C_PaymentTerm_ID, i.DateInvoiced) AS DueDate, + paymentTermDueDays(i.C_PaymentTerm_ID, i.DateInvoiced, getdate()) AS DaysDue, + addDays(i.DateInvoiced,p.DiscountDays) AS DiscountDate, + ROUND(i.GrandTotal*p.Discount/100,2) AS DiscountAmt, + i.GrandTotal, + invoicePaid(i.C_Invoice_ID, i.C_Currency_ID, 1) AS PaidAmt, + invoiceOpen(i.C_Invoice_ID,0) AS OpenAmt, + i.C_Currency_ID, i.C_ConversionType_ID, + i.C_PaymentTerm_ID, + i.IsPayScheduleValid, cast(null as number) AS C_InvoicePaySchedule_ID, i.InvoiceCollectionType, + i.C_Campaign_ID, i.C_Project_ID, i.C_Activity_ID +FROM RV_C_Invoice i + INNER JOIN C_PaymentTerm p ON (i.C_PaymentTerm_ID=p.C_PaymentTerm_ID) +WHERE -- i.IsPaid='N' + invoiceOpen(i.C_Invoice_ID,0) <> 0 + AND i.IsPayScheduleValid<>'Y' + AND i.DocStatus IN ('CO','CL') +UNION +SELECT i.AD_Org_ID, i.AD_Client_ID, + i.DocumentNo, i.C_Invoice_ID, i.C_Order_ID, i.C_BPartner_ID, i.IsSOTrx, + i.DateInvoiced, i.DateAcct, + daysBetween(ips.DueDate,i.DateInvoiced) AS NetDays, + ips.DueDate, + daysBetween(getdate(),ips.DueDate) AS DaysDue, + ips.DiscountDate, + ips.DiscountAmt, + ips.DueAmt AS GrandTotal, + invoicePaid(i.C_Invoice_ID, i.C_Currency_ID, 1) AS PaidAmt, + invoiceOpen(i.C_Invoice_ID, ips.C_InvoicePaySchedule_ID) AS OpenAmt, + i.C_Currency_ID, i.C_ConversionType_ID, + i.C_PaymentTerm_ID, + i.IsPayScheduleValid, ips.C_InvoicePaySchedule_ID, i.InvoiceCollectionType, + i.C_Campaign_ID, i.C_Project_ID, i.C_Activity_ID +FROM RV_C_Invoice i + INNER JOIN C_InvoicePaySchedule ips ON (i.C_Invoice_ID=ips.C_Invoice_ID) +WHERE -- i.IsPaid='N' + invoiceOpen(i.C_Invoice_ID,ips.C_InvoicePaySchedule_ID) <> 0 + AND i.IsPayScheduleValid='Y' + AND i.DocStatus IN ('CO','CL') + AND ips.IsValid='Y'; + + + +CREATE OR REPLACE VIEW RV_OPENITEMTODATE +(AD_ORG_ID, AD_CLIENT_ID, DOCUMENTNO, C_INVOICE_ID, C_ORDER_ID, + C_BPARTNER_ID, ISSOTRX, DATEINVOICED, DATEACCT, NETDAYS, + DUEDATE, DAYSDUE, DISCOUNTDATE, DISCOUNTAMT, GRANDTOTAL, + --PAIDAMT, OPENAMT, + C_CURRENCY_ID, C_CONVERSIONTYPE_ID, C_PAYMENTTERM_ID, + ISPAYSCHEDULEVALID, C_INVOICEPAYSCHEDULE_ID, INVOICECOLLECTIONTYPE, C_CAMPAIGN_ID, C_PROJECT_ID, + C_ACTIVITY_ID) +AS +SELECT i.AD_Org_ID, i.AD_Client_ID, + i.DocumentNo, i.C_Invoice_ID, i.C_Order_ID, i.C_BPartner_ID, i.IsSOTrx, + i.DateInvoiced, i.DateAcct, + p.NetDays, + paymentTermDueDate(i.C_PaymentTerm_ID, i.DateInvoiced) AS DueDate, + paymentTermDueDays(i.C_PaymentTerm_ID, i.DateInvoiced, getdate()) AS DaysDue, + addDays(i.DateInvoiced,p.DiscountDays) AS DiscountDate, + ROUND(i.GrandTotal*p.Discount/100,2) AS DiscountAmt, + i.GrandTotal, + --invoicePaid(i.C_Invoice_ID, i.C_Currency_ID, 1) AS PaidAmt, + --invoiceOpen(i.C_Invoice_ID,0) AS OpenAmt, + i.C_Currency_ID, i.C_ConversionType_ID, + i.C_PaymentTerm_ID, + i.IsPayScheduleValid, cast(null as number) AS C_InvoicePaySchedule_ID, i.InvoiceCollectionType, + i.C_Campaign_ID, i.C_Project_ID, i.C_Activity_ID +FROM RV_C_Invoice i + INNER JOIN C_PaymentTerm p ON (i.C_PaymentTerm_ID=p.C_PaymentTerm_ID) +WHERE -- i.IsPaid='N' + --invoiceOpen(i.C_Invoice_ID,0) <> 0 AND + i.IsPayScheduleValid<>'Y' + AND i.DocStatus<>'DR' + AND i.DocStatus IN ('CO','CL') +UNION +SELECT i.AD_Org_ID, i.AD_Client_ID, + i.DocumentNo, i.C_Invoice_ID, i.C_Order_ID, i.C_BPartner_ID, i.IsSOTrx, + i.DateInvoiced, i.DateAcct, + daysBetween(ips.DueDate,i.DateInvoiced) AS NetDays, + ips.DueDate, + daysBetween(getdate(),ips.DueDate) AS DaysDue, + ips.DiscountDate, + ips.DiscountAmt, + ips.DueAmt AS GrandTotal, +-- invoicePaid(i.C_Invoice_ID, i.C_Currency_ID, 1) AS PaidAmt, +-- invoiceOpen(i.C_Invoice_ID, ips.C_InvoicePaySchedule_ID) AS OpenAmt, + i.C_Currency_ID, i.C_ConversionType_ID, + i.C_PaymentTerm_ID, + i.IsPayScheduleValid, ips.C_InvoicePaySchedule_ID, i.InvoiceCollectionType, + i.C_Campaign_ID, i.C_Project_ID, i.C_Activity_ID +FROM RV_C_Invoice i + INNER JOIN C_InvoicePaySchedule ips ON (i.C_Invoice_ID=ips.C_Invoice_ID) +WHERE -- i.IsPaid='N' + --invoiceOpen(i.C_Invoice_ID,ips.C_InvoicePaySchedule_ID) <> 0 AND + i.IsPayScheduleValid='Y' + AND i.DocStatus<>'DR' + AND i.DocStatus IN ('CO','CL') + AND ips.IsValid='Y'; + + + diff --git a/migration/353a-trunk/postgresql/419_BF2563594.sql b/migration/353a-trunk/postgresql/419_BF2563594.sql new file mode 100644 index 0000000000..806964a0f8 --- /dev/null +++ b/migration/353a-trunk/postgresql/419_BF2563594.sql @@ -0,0 +1,112 @@ +CREATE OR REPLACE VIEW RV_OPENITEM +(AD_ORG_ID, AD_CLIENT_ID, DOCUMENTNO, C_INVOICE_ID, C_ORDER_ID, + C_BPARTNER_ID, ISSOTRX, DATEINVOICED, DATEACCT, NETDAYS, + DUEDATE, DAYSDUE, DISCOUNTDATE, DISCOUNTAMT, GRANDTOTAL, + PAIDAMT, OPENAMT, + C_CURRENCY_ID, C_CONVERSIONTYPE_ID, C_PAYMENTTERM_ID, + ISPAYSCHEDULEVALID, C_INVOICEPAYSCHEDULE_ID, INVOICECOLLECTIONTYPE, C_CAMPAIGN_ID, C_PROJECT_ID, + C_ACTIVITY_ID) +AS +SELECT i.AD_Org_ID, i.AD_Client_ID, + i.DocumentNo, i.C_Invoice_ID, i.C_Order_ID, i.C_BPartner_ID, i.IsSOTrx, + i.DateInvoiced, i.DateAcct, + p.NetDays, + paymentTermDueDate(i.C_PaymentTerm_ID, i.DateInvoiced) AS DueDate, + paymentTermDueDays(i.C_PaymentTerm_ID, i.DateInvoiced, getdate()) AS DaysDue, + addDays(i.DateInvoiced,p.DiscountDays) AS DiscountDate, + ROUND(i.GrandTotal*p.Discount/100,2) AS DiscountAmt, + i.GrandTotal, + invoicePaid(i.C_Invoice_ID, i.C_Currency_ID, 1) AS PaidAmt, + invoiceOpen(i.C_Invoice_ID,0) AS OpenAmt, + i.C_Currency_ID, i.C_ConversionType_ID, + i.C_PaymentTerm_ID, + i.IsPayScheduleValid, cast(null as numeric) AS C_InvoicePaySchedule_ID, i.InvoiceCollectionType, + i.C_Campaign_ID, i.C_Project_ID, i.C_Activity_ID +FROM RV_C_Invoice i + INNER JOIN C_PaymentTerm p ON (i.C_PaymentTerm_ID=p.C_PaymentTerm_ID) +WHERE -- i.IsPaid='N' + invoiceOpen(i.C_Invoice_ID,0) <> 0 AND + i.IsPayScheduleValid<>'Y' + AND i.DocStatus IN ('CO','CL') +UNION +SELECT i.AD_Org_ID, i.AD_Client_ID, + i.DocumentNo, i.C_Invoice_ID, i.C_Order_ID, i.C_BPartner_ID, i.IsSOTrx, + i.DateInvoiced, i.DateAcct, + daysBetween(ips.DueDate,i.DateInvoiced) AS NetDays, + ips.DueDate, + daysBetween(getdate(),ips.DueDate) AS DaysDue, + ips.DiscountDate, + ips.DiscountAmt, + ips.DueAmt AS GrandTotal, + invoicePaid(i.C_Invoice_ID, i.C_Currency_ID, 1) AS PaidAmt, + invoiceOpen(i.C_Invoice_ID, ips.C_InvoicePaySchedule_ID) AS OpenAmt, + i.C_Currency_ID, i.C_ConversionType_ID, + i.C_PaymentTerm_ID, + i.IsPayScheduleValid, ips.C_InvoicePaySchedule_ID, i.InvoiceCollectionType, + i.C_Campaign_ID, i.C_Project_ID, i.C_Activity_ID +FROM RV_C_Invoice i + INNER JOIN C_InvoicePaySchedule ips ON (i.C_Invoice_ID=ips.C_Invoice_ID) +WHERE -- i.IsPaid='N' + invoiceOpen(i.C_Invoice_ID,ips.C_InvoicePaySchedule_ID) <> 0 AND + i.IsPayScheduleValid='Y' + AND i.DocStatus IN ('CO','CL') + AND ips.IsValid='Y'; + + + +CREATE OR REPLACE VIEW RV_OPENITEMTODATE +(AD_ORG_ID, AD_CLIENT_ID, DOCUMENTNO, C_INVOICE_ID, C_ORDER_ID, + C_BPARTNER_ID, ISSOTRX, DATEINVOICED, DATEACCT, NETDAYS, + DUEDATE, DAYSDUE, DISCOUNTDATE, DISCOUNTAMT, GRANDTOTAL, + --PAIDAMT, OPENAMT, + C_CURRENCY_ID, C_CONVERSIONTYPE_ID, C_PAYMENTTERM_ID, + ISPAYSCHEDULEVALID, C_INVOICEPAYSCHEDULE_ID, INVOICECOLLECTIONTYPE, C_CAMPAIGN_ID, C_PROJECT_ID, + C_ACTIVITY_ID) +AS +SELECT i.AD_Org_ID, i.AD_Client_ID, + i.DocumentNo, i.C_Invoice_ID, i.C_Order_ID, i.C_BPartner_ID, i.IsSOTrx, + i.DateInvoiced, i.DateAcct, + p.NetDays, + paymentTermDueDate(i.C_PaymentTerm_ID, i.DateInvoiced) AS DueDate, + paymentTermDueDays(i.C_PaymentTerm_ID, i.DateInvoiced, getdate()) AS DaysDue, + addDays(i.DateInvoiced,p.DiscountDays) AS DiscountDate, + ROUND(i.GrandTotal*p.Discount/100,2) AS DiscountAmt, + i.GrandTotal, + --invoicePaid(i.C_Invoice_ID, i.C_Currency_ID, 1) AS PaidAmt, + --invoiceOpen(i.C_Invoice_ID,0) AS OpenAmt, + i.C_Currency_ID, i.C_ConversionType_ID, + i.C_PaymentTerm_ID, + i.IsPayScheduleValid, cast(null as numeric) AS C_InvoicePaySchedule_ID, i.InvoiceCollectionType, + i.C_Campaign_ID, i.C_Project_ID, i.C_Activity_ID +FROM RV_C_Invoice i + INNER JOIN C_PaymentTerm p ON (i.C_PaymentTerm_ID=p.C_PaymentTerm_ID) +WHERE -- i.IsPaid='N' + --invoiceOpen(i.C_Invoice_ID,0) <> 0 AND + i.IsPayScheduleValid<>'Y' + AND i.DocStatus IN ('CO','CL') +UNION +SELECT i.AD_Org_ID, i.AD_Client_ID, + i.DocumentNo, i.C_Invoice_ID, i.C_Order_ID, i.C_BPartner_ID, i.IsSOTrx, + i.DateInvoiced, i.DateAcct, + daysBetween(ips.DueDate,i.DateInvoiced) AS NetDays, + ips.DueDate, + daysBetween(getdate(),ips.DueDate) AS DaysDue, + ips.DiscountDate, + ips.DiscountAmt, + ips.DueAmt AS GrandTotal, + --invoicePaid(i.C_Invoice_ID, i.C_Currency_ID, 1) AS PaidAmt, + --invoiceOpen(i.C_Invoice_ID, ips.C_InvoicePaySchedule_ID) AS OpenAmt, + i.C_Currency_ID, i.C_ConversionType_ID, + i.C_PaymentTerm_ID, + i.IsPayScheduleValid, ips.C_InvoicePaySchedule_ID, i.InvoiceCollectionType, + i.C_Campaign_ID, i.C_Project_ID, i.C_Activity_ID +FROM RV_C_Invoice i + INNER JOIN C_InvoicePaySchedule ips ON (i.C_Invoice_ID=ips.C_Invoice_ID) +WHERE -- i.IsPaid='N' + --invoiceOpen(i.C_Invoice_ID,ips.C_InvoicePaySchedule_ID) <> 0 AND + i.IsPayScheduleValid='Y' + AND i.DocStatus IN ('CO','CL') + AND ips.IsValid='Y'; + + +