Ticket #1001025: Review the views to provide more information

This commit is contained in:
Elaine Tan 2013-03-20 15:13:04 +08:00
parent 15b1404428
commit 27df258e9d
94 changed files with 128524 additions and 4321 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1,50 +1,13 @@
CREATE OR REPLACE VIEW C_DUNNING_LINE_V
(AD_CLIENT_ID, AD_ORG_ID, ISACTIVE, CREATED, CREATEDBY,
UPDATED, UPDATEDBY, AD_LANGUAGE, C_DUNNINGRUNLINE_ID, C_DUNNINGRUNENTRY_ID,
AMT, CONVERTEDAMT, DAYSDUE, TIMESDUNNED, INTERESTAMT,
FEEAMT, TOTALAMT, C_INVOICE_ID, ISSOTRX, DOCUMENTNO,
DOCSTATUS, DATETRX, C_DOCTYPE_ID, DOCUMENTTYPE, DESCRIPTION,
C_CURRENCY_ID, C_CAMPAIGN_ID, C_PROJECT_ID, C_ACTIVITY_ID, USER1_ID,
USER2_ID, DATEACCT, C_CONVERSIONTYPE_ID, AD_ORGTRX_ID, POREFERENCE,
DATEORDERED, DATEINVOICED, ISINDISPUTE, PAYMENTTERM, C_CHARGE_ID,
CHARGEAMT, TOTALLINES, GRANDTOTAL, AMTINWORDS, M_PRICELIST_ID,
ISPAID, ISALLOCATED, TENDERTYPE, DISCOUNTAMT)
AS
SELECT drl.AD_Client_ID, drl.AD_Org_ID, drl.IsActive, drl.Created, drl.CreatedBy, drl.Updated, drl.UpdatedBy,
cast('en_US' as varchar2(6)) AS AD_Language,
drl.C_DunningRunLine_ID, drl.C_DunningRunEntry_ID,
drl.Amt, drl.ConvertedAmt, drl.DaysDue, drl.TimesDunned,
drl.InterestAmt, drl.FeeAmt, drl.TotalAmt,
drl.C_Invoice_ID,
COALESCE(i.IsSOTrx,p.IsReceipt) AS IsSOTrx,
COALESCE(i.DocumentNo,p.DocumentNo) AS DocumentNo,
COALESCE(i.DocStatus,p.DocStatus) AS DocStatus,
COALESCE(i.DateInvoiced, p.DateTrx) AS DateTrx,
COALESCE(i.C_DocType_ID,p.C_DocType_ID) AS C_DocType_ID,
COALESCE(dt.PrintName,dtp.PrintName) AS DocumentType,
COALESCE(i.Description,p.Description) AS Description,
COALESCE(i.C_Currency_ID,p.C_Currency_ID) AS C_Currency_ID,
COALESCE(i.C_Campaign_ID,p.C_Campaign_ID) AS C_Campaign_ID,
COALESCE(i.C_Project_ID,p.C_Project_ID) AS C_Project_ID,
COALESCE(i.C_Activity_ID,p.C_Activity_ID) AS C_Activity_ID,
COALESCE(i.User1_ID,p.User1_ID) AS User1_ID,
COALESCE(i.User2_ID,p.User2_ID) AS User2_ID,
COALESCE(i.DateAcct,p.DateAcct) AS DateAcct,
COALESCE(i.C_ConversionType_ID,i.C_ConversionType_ID) AS C_ConversionType_ID,
COALESCE(i.AD_OrgTrx_ID,p.AD_OrgTrx_ID) AS AD_OrgTrx_ID,
i.POReference, i.DateOrdered,
i.DateInvoiced, i.IsInDispute,
pt.Name AS PaymentTerm,
i.C_Charge_ID, i.ChargeAmt,
i.TotalLines, i.GrandTotal, i.GrandTotal AS AmtInWords,
i.M_PriceList_ID, i.IsPaid,
p.IsAllocated, p.TenderType, p.DiscountAmt
FROM C_DunningRunLine drl
LEFT OUTER JOIN C_Invoice i ON (drl.C_Invoice_ID=i.C_Invoice_ID)
LEFT OUTER JOIN C_DocType dt ON (i.C_DocType_ID=dt.C_DocType_ID)
LEFT OUTER JOIN C_PaymentTerm pt ON (i.C_PaymentTerm_ID=pt.C_PaymentTerm_ID)
LEFT OUTER JOIN C_Payment p ON (drl.C_Payment_ID=p.C_Payment_ID)
LEFT OUTER JOIN C_DocType dtp ON (p.C_DocType_ID=dtp.C_DocType_ID);
DROP VIEW c_dunning_line_v;
CREATE OR REPLACE VIEW c_dunning_line_v AS
SELECT drl.ad_client_id, drl.ad_org_id, drl.isactive, drl.created, drl.createdby, drl.updated, drl.updatedby,
'en_US' AS ad_language,
drl.c_dunningrunline_id, drl.c_dunningrunentry_id, drl.amt, drl.convertedamt, drl.daysdue, drl.timesdunned, drl.interestamt, drl.feeamt, drl.totalamt, drl.c_invoice_id, COALESCE(i.issotrx, p.isreceipt) AS issotrx, COALESCE(i.documentno, p.documentno) AS documentno, COALESCE(i.docstatus, p.docstatus) AS docstatus, COALESCE(i.dateinvoiced, p.datetrx) AS datetrx, COALESCE(i.c_doctype_id, p.c_doctype_id) AS c_doctype_id, COALESCE(dt.printname, dtp.printname) AS documenttype, COALESCE(i.description, p.description) AS description, COALESCE(i.c_currency_id, p.c_currency_id) AS c_currency_id, COALESCE(i.c_campaign_id, p.c_campaign_id) AS c_campaign_id, COALESCE(i.c_project_id, p.c_project_id) AS c_project_id, COALESCE(i.c_activity_id, p.c_activity_id) AS c_activity_id, COALESCE(i.user1_id, p.user1_id) AS user1_id, COALESCE(i.user2_id, p.user2_id) AS user2_id, COALESCE(i.dateacct, p.dateacct) AS dateacct, COALESCE(i.c_conversiontype_id, p.c_conversiontype_id) AS c_conversiontype_id, COALESCE(i.ad_orgtrx_id, p.ad_orgtrx_id) AS ad_orgtrx_id, i.poreference, i.dateordered, i.dateinvoiced, i.isindispute, pt.name AS paymentterm, i.c_charge_id, i.chargeamt, i.totallines, i.grandtotal, i.grandtotal AS amtinwords, i.m_pricelist_id, i.ispaid, p.isallocated, p.tendertype, p.discountamt, drl.c_invoicepayschedule_id, drl.c_payment_id, drl.isindispute AS c_dunningrunline_isindispute, drl.openamt, drl.processed AS c_dunningrunline_processed, i.ad_org_id AS c_invoice_ad_org_id, i.ad_user_id, i.c_bpartner_id AS c_invoice_c_bpartner_id, i.c_bpartner_location_id, i.c_doctypetarget_id, i.c_dunninglevel_id, i.c_order_id AS c_invoice_c_order_id, i.c_payment_id AS c_invoice_c_payment_id, i.created AS c_invoice_created, i.createdby AS c_invoice_createdby, i.dateprinted, i.docaction, i.dunninggrace, i.generateto, i.invoicecollectiontype, i.isactive AS c_invoice_isactive, i.isapproved AS c_invoice_isapproved, i.isdiscountprinted, i.ispayschedulevalid, i.isprinted, i.isselfservice AS c_invoice_isselfservice, i.istaxincluded, i.istransferred, i.m_rma_id, i.paymentrule, i.posted AS c_invoice_posted, i.processedon AS c_invoice_processedon, i.processing, i.ref_invoice_id, i.reversal_id AS c_invoice_reversal_id, i.salesrep_id, i.sendemail, i.updated AS c_invoice_updated, i.updatedby AS c_invoice_updatedby, pt.ad_org_id AS c_paymentterm_ad_org_id, pt.afterdelivery, pt.c_paymentterm_id, pt.description AS c_paymentterm_description, pt.discount, pt.discount2, pt.discountdays, pt.discountdays2, pt.documentnote, pt.fixmonthcutoff, pt.fixmonthday, pt.fixmonthoffset, pt.gracedays, pt.isactive AS c_paymentterm_isactive, pt.isduefixed, pt.isnextbusinessday, pt.isvalid, pt.netday, pt.netdays, pt.paymenttermusage, pt.value AS c_paymentterm_value, p.a_city, p.a_country, p.ad_org_id AS c_payment_ad_org_id, p.a_email, p.a_ident_dl, p.a_name, p.a_state, p.a_street, p.a_zip, p.c_bpartner_id AS c_payment_c_bpartner_id, p.c_charge_id AS c_payment_c_charge_id, p.chargeamt AS c_payment_chargeamt, p.checkno, p.c_invoice_id AS c_payment_c_invoice_id, p.c_order_id AS c_payment_c_order_id, p.c_paymentbatch_id, p.created AS c_payment_created, p.createdby AS c_payment_createdby, p.isactive AS c_payment_isactive, p.isapproved, p.isdelayedcapture, p.isonline, p.isoverunderpayment, p.isprepayment, p.isreconciled, p.isselfservice AS c_payment_isselfservice, p.micr, p.orig_trxid, p.overunderamt, p.payamt, p.ponum, p.posted AS c_payment_posted, p.processed AS c_payment_processed, p.processedon AS c_payment_processedon, p.r_authcode, p.r_authcode_dc, p.r_avsaddr, p.r_avszip, p.r_cvv2match, p.ref_payment_id, p.reversal_id AS c_payment_reversal_id, p.r_info, p.routingno, p.r_pnref, p.r_pnref_dc, p.r_respmsg, p.r_result, p.swipe, p.taxamt, p.trxtype, p.updated AS c_payment_updated, p.updatedby AS c_payment_updatedby, p.voiceauthcode, p.writeoffamt
FROM c_dunningrunline drl
LEFT JOIN c_invoice i ON drl.c_invoice_id = i.c_invoice_id
LEFT JOIN c_doctype dt ON i.c_doctype_id = dt.c_doctype_id
LEFT JOIN c_paymentterm pt ON i.c_paymentterm_id = pt.c_paymentterm_id
LEFT JOIN c_payment p ON drl.c_payment_id = p.c_payment_id
LEFT JOIN c_doctype dtp ON p.c_doctype_id = dtp.c_doctype_id;

View File

@ -1,52 +1,13 @@
CREATE OR REPLACE VIEW C_DUNNING_LINE_VT
(AD_CLIENT_ID, AD_ORG_ID, ISACTIVE, CREATED, CREATEDBY,
UPDATED, UPDATEDBY, AD_LANGUAGE, C_DUNNINGRUNLINE_ID, C_DUNNINGRUNENTRY_ID,
AMT, CONVERTEDAMT, DAYSDUE, TIMESDUNNED, INTERESTAMT,
FEEAMT, TOTALAMT, C_INVOICE_ID, ISSOTRX, DOCUMENTNO,
DOCSTATUS, DATETRX, C_DOCTYPE_ID, DOCUMENTTYPE, DESCRIPTION,
C_CURRENCY_ID, C_CAMPAIGN_ID, C_PROJECT_ID, C_ACTIVITY_ID, USER1_ID,
USER2_ID, DATEACCT, C_CONVERSIONTYPE_ID, AD_ORGTRX_ID, POREFERENCE,
DATEORDERED, DATEINVOICED, ISINDISPUTE, PAYMENTTERM, C_CHARGE_ID,
CHARGEAMT, TOTALLINES, GRANDTOTAL, AMTINWORDS, M_PRICELIST_ID,
ISPAID, ISALLOCATED, TENDERTYPE, DISCOUNTAMT)
AS
SELECT drl.AD_Client_ID, drl.AD_Org_ID, drl.IsActive, drl.Created, drl.CreatedBy, drl.Updated, drl.UpdatedBy,
COALESCE(dt.AD_Language,dtp.AD_Language) AS AD_Language,
drl.C_DunningRunLine_ID, drl.C_DunningRunEntry_ID,
drl.Amt, drl.ConvertedAmt, drl.DaysDue, drl.TimesDunned,
drl.InterestAmt, drl.FeeAmt, drl.TotalAmt,
drl.C_Invoice_ID,
COALESCE(i.IsSOTrx,p.IsReceipt) AS IsSOTrx,
COALESCE(i.DocumentNo,p.DocumentNo) AS DocumentNo,
COALESCE(i.DocStatus,p.DocStatus) AS DocStatus,
COALESCE(i.DateInvoiced, p.DateTrx) AS DateTrx,
COALESCE(i.C_DocType_ID,p.C_DocType_ID) AS C_DocType_ID,
COALESCE(dt.PrintName,dtp.PrintName) AS DocumentType,
COALESCE(i.Description,p.Description) AS Description,
COALESCE(i.C_Currency_ID,p.C_Currency_ID) AS C_Currency_ID,
COALESCE(i.C_Campaign_ID,p.C_Campaign_ID) AS C_Campaign_ID,
COALESCE(i.C_Project_ID,p.C_Project_ID) AS C_Project_ID,
COALESCE(i.C_Activity_ID,p.C_Activity_ID) AS C_Activity_ID,
COALESCE(i.User1_ID,p.User1_ID) AS User1_ID,
COALESCE(i.User2_ID,p.User2_ID) AS User2_ID,
COALESCE(i.DateAcct,p.DateAcct) AS DateAcct,
COALESCE(i.C_ConversionType_ID,i.C_ConversionType_ID) AS C_ConversionType_ID,
COALESCE(i.AD_OrgTrx_ID,p.AD_OrgTrx_ID) AS AD_OrgTrx_ID,
i.POReference, i.DateOrdered,
i.DateInvoiced, i.IsInDispute,
pt.Name AS PaymentTerm,
i.C_Charge_ID, i.ChargeAmt,
i.TotalLines, i.GrandTotal, i.GrandTotal AS AmtInWords,
i.M_PriceList_ID, i.IsPaid,
p.IsAllocated, p.TenderType, p.DiscountAmt
FROM C_DunningRunLine drl
LEFT OUTER JOIN C_Invoice i ON (drl.C_Invoice_ID=i.C_Invoice_ID)
LEFT OUTER JOIN C_DocType_Trl dt ON (i.C_DocType_ID=dt.C_DocType_ID)
LEFT OUTER JOIN C_PaymentTerm_Trl pt ON (i.C_PaymentTerm_ID=pt.C_PaymentTerm_ID
AND pt.AD_Language=dt.AD_Language)
LEFT OUTER JOIN C_Payment p ON (drl.C_Payment_ID=p.C_Payment_ID)
LEFT OUTER JOIN C_DocType_Trl dtp ON (p.C_DocType_ID=dtp.C_DocType_ID)
WHERE COALESCE(dt.AD_Language,dtp.AD_Language)=COALESCE(dtp.AD_Language,dt.AD_Language);
DROP VIEW c_dunning_line_vt;
CREATE OR REPLACE VIEW c_dunning_line_vt AS
SELECT drl.ad_client_id, drl.ad_org_id, drl.isactive, drl.created, drl.createdby, drl.updated, drl.updatedby, COALESCE(dt.ad_language, dtp.ad_language) AS ad_language, drl.c_dunningrunline_id, drl.c_dunningrunentry_id, drl.amt, drl.convertedamt, drl.daysdue, drl.timesdunned, drl.interestamt, drl.feeamt, drl.totalamt, drl.c_invoice_id, COALESCE(i.issotrx, p.isreceipt) AS issotrx, COALESCE(i.documentno, p.documentno) AS documentno, COALESCE(i.docstatus, p.docstatus) AS docstatus, COALESCE(i.dateinvoiced, p.datetrx) AS datetrx, COALESCE(i.c_doctype_id, p.c_doctype_id) AS c_doctype_id, COALESCE(dt.printname, dtp.printname) AS documenttype, COALESCE(i.description, p.description) AS description, COALESCE(i.c_currency_id, p.c_currency_id) AS c_currency_id, COALESCE(i.c_campaign_id, p.c_campaign_id) AS c_campaign_id, COALESCE(i.c_project_id, p.c_project_id) AS c_project_id, COALESCE(i.c_activity_id, p.c_activity_id) AS c_activity_id, COALESCE(i.user1_id, p.user1_id) AS user1_id, COALESCE(i.user2_id, p.user2_id) AS user2_id, COALESCE(i.dateacct, p.dateacct) AS dateacct, COALESCE(i.c_conversiontype_id, p.c_conversiontype_id) AS c_conversiontype_id, COALESCE(i.ad_orgtrx_id, p.ad_orgtrx_id) AS ad_orgtrx_id, i.poreference, i.dateordered, i.dateinvoiced, i.isindispute, ptt.name AS paymentterm, i.c_charge_id, i.chargeamt, i.totallines, i.grandtotal, i.grandtotal AS amtinwords, i.m_pricelist_id, i.ispaid, p.isallocated, p.tendertype, p.discountamt, drl.c_invoicepayschedule_id, drl.c_payment_id, drl.isindispute AS c_dunningrunline_isindispute, drl.openamt, drl.processed AS c_dunningrunline_processed, i.ad_org_id AS c_invoice_ad_org_id, i.ad_user_id, i.c_bpartner_id AS c_invoice_c_bpartner_id, i.c_bpartner_location_id, i.c_doctypetarget_id, i.c_dunninglevel_id, i.c_order_id AS c_invoice_c_order_id, i.c_payment_id AS c_invoice_c_payment_id, i.created AS c_invoice_created, i.createdby AS c_invoice_createdby, i.dateprinted, i.docaction, i.dunninggrace, i.generateto, i.invoicecollectiontype, i.isactive AS c_invoice_isactive, i.isapproved AS c_invoice_isapproved, i.isdiscountprinted, i.ispayschedulevalid, i.isprinted, i.isselfservice AS c_invoice_isselfservice, i.istaxincluded, i.istransferred, i.m_rma_id, i.paymentrule, i.posted AS c_invoice_posted, i.processedon AS c_invoice_processedon, i.processing, i.ref_invoice_id, i.reversal_id AS c_invoice_reversal_id, i.salesrep_id, i.sendemail, i.updated AS c_invoice_updated, i.updatedby AS c_invoice_updatedby, ptt.ad_org_id AS c_paymentterm_ad_org_id, pt.afterdelivery, pt.c_paymentterm_id, ptt.description AS c_paymentterm_description, pt.discount, pt.discount2, pt.discountdays, pt.discountdays2, ptt.documentnote, pt.fixmonthcutoff, pt.fixmonthday, pt.fixmonthoffset, pt.gracedays, ptt.isactive AS c_paymentterm_isactive, pt.isduefixed, pt.isnextbusinessday, pt.isvalid, pt.netday, pt.netdays, pt.paymenttermusage, pt.value AS c_paymentterm_value, p.a_city, p.a_country, p.ad_org_id AS c_payment_ad_org_id, p.a_email, p.a_ident_dl, p.a_name, p.a_state, p.a_street, p.a_zip, p.c_bpartner_id AS c_payment_c_bpartner_id, p.c_charge_id AS c_payment_c_charge_id, p.chargeamt AS c_payment_chargeamt, p.checkno, p.c_invoice_id AS c_payment_c_invoice_id, p.c_order_id AS c_payment_c_order_id, p.c_paymentbatch_id, p.created AS c_payment_created, p.createdby AS c_payment_createdby, p.isactive AS c_payment_isactive, p.isapproved, p.isdelayedcapture, p.isonline, p.isoverunderpayment, p.isprepayment, p.isreconciled, p.isselfservice AS c_payment_isselfservice, p.micr, p.orig_trxid, p.overunderamt, p.payamt, p.ponum, p.posted AS c_payment_posted, p.processed AS c_payment_processed, p.processedon AS c_payment_processedon, p.r_authcode, p.r_authcode_dc, p.r_avsaddr, p.r_avszip, p.r_cvv2match, p.ref_payment_id, p.reversal_id AS c_payment_reversal_id, p.r_info, p.routingno, p.r_pnref, p.r_pnref_dc, p.r_respmsg, p.r_result, p.swipe, p.taxamt, p.trxtype, p.updated AS c_payment_updated, p.updatedby AS c_payment_updatedby, p.voiceauthcode, p.writeoffamt
FROM c_dunningrunline drl
LEFT JOIN c_invoice i ON drl.c_invoice_id = i.c_invoice_id
LEFT JOIN c_doctype_trl dt ON i.c_doctype_id = dt.c_doctype_id
LEFT JOIN c_paymentterm pt ON i.c_paymentterm_id = pt.c_paymentterm_id
LEFT JOIN c_paymentterm_trl ptt ON i.c_paymentterm_id = ptt.c_paymentterm_id AND ptt.ad_language = dt.ad_language
LEFT JOIN c_payment p ON drl.c_payment_id = p.c_payment_id
LEFT JOIN c_doctype_trl dtp ON p.c_doctype_id = dtp.c_doctype_id
WHERE COALESCE(dt.ad_language, dtp.ad_language) = COALESCE(dtp.ad_language, dt.ad_language);

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1,56 +1,44 @@
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 number) 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';
CREATE OR REPLACE VIEW c_invoice_v 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, NULL 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.0)
ELSE 1.0
END AS multiplier,
CASE
WHEN charat(d.docbasetype, 2) = 'P' THEN (-1.0)
ELSE 1.0
END AS multiplierap, d.docbasetype, paymenttermduedate(i.c_paymentterm_id, i.dateinvoiced) AS duedate, i.ad_orgtrx_id, i.c_payment_id, i.isselfservice, i.posted, i.processedon, i.reversal_id
FROM c_invoice i
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, i.ad_orgtrx_id, i.c_payment_id, i.isselfservice, i.posted, i.processedon, i.reversal_id
FROM c_invoice i
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' AND ips.isvalid = 'Y';

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1,42 +1,28 @@
CREATE OR REPLACE VIEW C_PAYMENT_V
(C_PAYMENT_ID, AD_CLIENT_ID, AD_ORG_ID, ISACTIVE, CREATED,
CREATEDBY, UPDATED, UPDATEDBY, DOCUMENTNO, DATETRX,
ISRECEIPT, C_DOCTYPE_ID, TRXTYPE, C_BANKACCOUNT_ID, C_BPARTNER_ID,
C_INVOICE_ID, C_BP_BANKACCOUNT_ID, C_PAYMENTBATCH_ID, TENDERTYPE, CREDITCARDTYPE,
CREDITCARDNUMBER, CREDITCARDVV, CREDITCARDEXPMM, CREDITCARDEXPYY, MICR,
ROUTINGNO, ACCOUNTNO, CHECKNO, A_NAME, A_STREET,
A_CITY, A_STATE, A_ZIP, A_IDENT_DL, A_IDENT_SSN,
A_EMAIL, VOICEAUTHCODE, ORIG_TRXID, PONUM, C_CURRENCY_ID,
C_CONVERSIONTYPE_ID, PAYAMT, DISCOUNTAMT, WRITEOFFAMT, TAXAMT,
OVERUNDERAMT, MULTIPLIERAP, ISOVERUNDERPAYMENT, ISAPPROVED, R_PNREF,
R_RESULT, R_RESPMSG, R_AUTHCODE, R_AVSADDR, R_AVSZIP,
R_INFO, PROCESSING, OPROCESSING, DOCSTATUS, DOCACTION,
ISPREPAYMENT, C_CHARGE_ID, ISRECONCILED, ISALLOCATED, ISONLINE,
PROCESSED, POSTED, C_CAMPAIGN_ID, C_PROJECT_ID, C_ACTIVITY_ID)
AS
SELECT C_Payment_ID, AD_Client_ID, AD_Org_ID, IsActive, Created, CreatedBy, Updated, UpdatedBy,
DocumentNo, DateTrx, IsReceipt, C_DocType_ID, TrxType,
C_BankAccount_ID, C_BPartner_ID, C_Invoice_ID, C_BP_BankAccount_ID, C_PaymentBatch_ID,
TenderType, CreditCardType, CreditCardNumber, CreditCardVV, CreditCardExpMM, CreditCardExpYY,
Micr, RoutingNo, AccountNo, CheckNo,
A_Name, A_Street, A_City, A_State, A_Zip, A_Ident_DL, A_Ident_SSN, A_EMail,
VoiceAuthCode, Orig_TrxID, PONum,
C_Currency_ID, C_ConversionType_ID,
CASE IsReceipt WHEN 'Y' THEN PayAmt ELSE PayAmt*-1 END AS PayAmt,
CASE IsReceipt WHEN 'Y' THEN DiscountAmt ELSE DiscountAmt*-1 END AS DiscountAmt,
CASE IsReceipt WHEN 'Y' THEN WriteOffAmt ELSE WriteOffAmt*-1 END AS WriteOffAmt,
CASE IsReceipt WHEN 'Y' THEN TaxAmt ELSE TaxAmt*-1 END AS TaxAmt,
CASE IsReceipt WHEN 'Y' THEN OverUnderAmt ELSE OverUnderAmt*-1 END AS OverUnderAmt,
CASE IsReceipt WHEN 'Y' THEN 1 ELSE -1 END AS MultiplierAP,
IsOverUnderPayment, IsApproved,
R_PnRef, R_Result, R_RespMsg, R_AuthCode, R_AvsAddr, R_AvsZip, R_Info,
Processing, OProcessing, DocStatus, DocAction,
IsPrepayment, C_Charge_ID,
IsReconciled, IsAllocated, IsOnline, Processed, Posted,
C_Campaign_ID, C_Project_ID, C_Activity_ID
FROM C_Payment;
--COMMENT ON TABLE C_PAYMENT_V IS 'Payment Information corrected for AP/AR';
CREATE OR REPLACE VIEW c_payment_v AS
SELECT c_payment.c_payment_id, c_payment.ad_client_id, c_payment.ad_org_id, c_payment.isactive, c_payment.created, c_payment.createdby, c_payment.updated, c_payment.updatedby, c_payment.documentno, c_payment.datetrx, c_payment.isreceipt, c_payment.c_doctype_id, c_payment.trxtype, c_payment.c_bankaccount_id, c_payment.c_bpartner_id, c_payment.c_invoice_id, c_payment.c_bp_bankaccount_id, c_payment.c_paymentbatch_id, c_payment.tendertype, c_payment.creditcardtype, c_payment.creditcardnumber, c_payment.creditcardvv, c_payment.creditcardexpmm, c_payment.creditcardexpyy, c_payment.micr, c_payment.routingno, c_payment.accountno, c_payment.checkno, c_payment.a_name, c_payment.a_street, c_payment.a_city, c_payment.a_state, c_payment.a_zip, c_payment.a_ident_dl, c_payment.a_ident_ssn, c_payment.a_email, c_payment.voiceauthcode, c_payment.orig_trxid, c_payment.ponum, c_payment.c_currency_id, c_payment.c_conversiontype_id,
CASE c_payment.isreceipt
WHEN 'Y' THEN c_payment.payamt
ELSE c_payment.payamt * (-1)
END AS payamt,
CASE c_payment.isreceipt
WHEN 'Y' THEN c_payment.discountamt
ELSE c_payment.discountamt * (-1)
END AS discountamt,
CASE c_payment.isreceipt
WHEN 'Y' THEN c_payment.writeoffamt
ELSE c_payment.writeoffamt * (-1)
END AS writeoffamt,
CASE c_payment.isreceipt
WHEN 'Y' THEN c_payment.taxamt
ELSE c_payment.taxamt * (-1)
END AS taxamt,
CASE c_payment.isreceipt
WHEN 'Y' THEN c_payment.overunderamt
ELSE c_payment.overunderamt * (-1)
END AS overunderamt,
CASE c_payment.isreceipt
WHEN 'Y' THEN 1
ELSE (-1)
END AS multiplierap, c_payment.isoverunderpayment, c_payment.isapproved, c_payment.r_pnref, c_payment.r_result, c_payment.r_respmsg, c_payment.r_authcode, c_payment.r_avsaddr, c_payment.r_avszip, c_payment.r_info, c_payment.processing, c_payment.oprocessing, c_payment.docstatus, c_payment.docaction, c_payment.isprepayment, c_payment.c_charge_id, c_payment.isreconciled, c_payment.isallocated, c_payment.isonline, c_payment.processed, c_payment.posted, c_payment.c_campaign_id, c_payment.c_project_id, c_payment.c_activity_id, c_payment.ad_orgtrx_id, c_payment.chargeamt, c_payment.c_order_id, c_payment.dateacct, c_payment.description, c_payment.isselfservice, c_payment.processedon, c_payment.reversal_id
FROM c_payment;

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1,17 +1,9 @@
CREATE OR REPLACE VIEW C_PAYSELECTION_REMITTANCE_V
(AD_CLIENT_ID, AD_ORG_ID, AD_LANGUAGE, C_PAYSELECTION_ID, C_PAYSELECTIONLINE_ID,
C_PAYSELECTIONCHECK_ID, PAYMENTRULE, LINE, OPENAMT, PAYAMT,
DISCOUNTAMT, DIFFERENCEAMT, C_BPARTNER_ID, DOCUMENTNO, DATEINVOICED,
GRANDTOTAL, AMTINWORDS)
AS
SELECT psl.AD_Client_ID, psl.AD_Org_ID,
cast('en_US' as varchar2(6)) AS AD_Language,
psl.C_PaySelection_ID, psl.C_PaySelectionLine_ID,
psl.C_PaySelectionCheck_ID,
psl.PaymentRule, psl.Line, psl.OpenAmt, psl.PayAmt, psl.DiscountAmt, psl.DifferenceAmt,
i.C_BPartner_ID, i.DocumentNo, i.DateInvoiced, i.GrandTotal, i.GrandTotal AS AmtInWords
FROM C_PaySelectionLine psl
INNER JOIN C_Invoice i ON (psl.C_Invoice_ID=i.C_Invoice_ID);
DROP VIEW c_payselection_remittance_v;
CREATE OR REPLACE VIEW c_payselection_remittance_v AS
SELECT psl.ad_client_id, psl.ad_org_id,
'en_US' AS ad_language,
psl.c_payselection_id, psl.c_payselectionline_id, psl.c_payselectioncheck_id, psl.paymentrule, psl.line, psl.openamt, psl.payamt, psl.discountamt, psl.differenceamt, i.c_bpartner_id, i.documentno, i.dateinvoiced, i.grandtotal, i.grandtotal AS amtinwords, psl.c_invoice_id, psl.created AS c_payselectionline_created, psl.createdby AS c_payselectionline_createdby, psl.description AS c_payselectionline_description, psl.isactive AS c_payselectionline_isactive, psl.ismanual, psl.issotrx AS c_payselectionline_issotrx, psl.processed, psl.updated AS c_payselectionline_updated, psl.updatedby AS c_payselectionline_updatedby, i.ad_org_id AS c_invoice_ad_org_id, i.ad_orgtrx_id, i.ad_user_id, i.c_activity_id, i.c_bpartner_location_id, i.c_campaign_id, i.c_charge_id, i.c_conversiontype_id, i.c_currency_id, i.c_doctype_id, i.c_doctypetarget_id, i.c_dunninglevel_id, i.chargeamt, i.c_payment_id, i.c_paymentterm_id, i.c_project_id, i.created AS c_invoice_created, i.createdby AS c_invoice_createdby, i.dateacct, i.dateordered, i.dateprinted, i.description AS c_invoice_description, i.docaction, i.docstatus, i.dunninggrace, i.generateto, i.invoicecollectiontype, i.isactive AS c_invoice_isactive, i.isapproved, i.isdiscountprinted, i.isindispute, i.ispayschedulevalid, i.isprinted, i.isselfservice AS c_invoice_isselfservice, i.issotrx AS c_invoice_issotrx, i.istaxincluded, i.istransferred, i.m_pricelist_id, i.m_rma_id, i.paymentrule AS c_invoice_paymentrule, i.poreference, i.posted, i.processedon, i.processing, i.ref_invoice_id, i.reversal_id, i.sendemail, i.totallines, i.updated AS c_invoice_updated, i.updatedby AS c_invoice_updatedby, i.user1_id, i.user2_id
FROM c_payselectionline psl
JOIN c_invoice i ON psl.c_invoice_id = i.c_invoice_id;

View File

@ -1,18 +1,8 @@
CREATE OR REPLACE VIEW C_PAYSELECTION_REMITTANCE_VT
(AD_CLIENT_ID, AD_ORG_ID, AD_LANGUAGE, C_PAYSELECTION_ID, C_PAYSELECTIONLINE_ID,
C_PAYSELECTIONCHECK_ID, PAYMENTRULE, LINE, OPENAMT, PAYAMT,
DISCOUNTAMT, DIFFERENCEAMT, C_BPARTNER_ID, DOCUMENTNO, DATEINVOICED,
GRANDTOTAL, AMTINWORDS)
AS
SELECT psl.AD_Client_ID, psl.AD_Org_ID,
l.AD_Language,
psl.C_PaySelection_ID, psl.C_PaySelectionLine_ID,
psl.C_PaySelectionCheck_ID,
psl.PaymentRule, psl.Line, psl.OpenAmt, psl.PayAmt, psl.DiscountAmt, psl.DifferenceAmt,
i.C_BPartner_ID, i.DocumentNo, i.DateInvoiced, i.GrandTotal, i.GrandTotal AS AmtInWords
FROM C_PaySelectionLine psl
INNER JOIN C_Invoice i ON (psl.C_Invoice_ID=i.C_Invoice_ID)
INNER JOIN AD_Language l ON (l.IsSystemLanguage='Y');
DROP VIEW c_payselection_remittance_vt;
CREATE OR REPLACE VIEW c_payselection_remittance_vt AS
SELECT psl.ad_client_id, psl.ad_org_id, l.ad_language, psl.c_payselection_id, psl.c_payselectionline_id, psl.c_payselectioncheck_id, psl.paymentrule, psl.line, psl.openamt, psl.payamt, psl.discountamt, psl.differenceamt, i.c_bpartner_id, i.documentno, i.dateinvoiced, i.grandtotal, i.grandtotal AS amtinwords, psl.c_invoice_id, psl.created AS c_payselectionline_created, psl.createdby AS c_payselectionline_createdby, psl.description AS c_payselectionline_description, psl.isactive AS c_payselectionline_isactive, psl.ismanual, psl.issotrx AS c_payselectionline_issotrx, psl.processed, psl.updated AS c_payselectionline_updated, psl.updatedby AS c_payselectionline_updatedby, i.ad_org_id AS c_invoice_ad_org_id, i.ad_orgtrx_id, i.ad_user_id, i.c_activity_id, i.c_bpartner_location_id, i.c_campaign_id, i.c_charge_id, i.c_conversiontype_id, i.c_currency_id, i.c_doctype_id, i.c_doctypetarget_id, i.c_dunninglevel_id, i.chargeamt, i.c_payment_id, i.c_paymentterm_id, i.c_project_id, i.created AS c_invoice_created, i.createdby AS c_invoice_createdby, i.dateacct, i.dateordered, i.dateprinted, i.description AS c_invoice_description, i.docaction, i.docstatus, i.dunninggrace, i.generateto, i.invoicecollectiontype, i.isactive AS c_invoice_isactive, i.isapproved, i.isdiscountprinted, i.isindispute, i.ispayschedulevalid, i.isprinted, i.isselfservice AS c_invoice_isselfservice, i.issotrx AS c_invoice_issotrx, i.istaxincluded, i.istransferred, i.m_pricelist_id, i.m_rma_id, i.paymentrule AS c_invoice_paymentrule, i.poreference, i.posted, i.processedon, i.processing, i.ref_invoice_id, i.reversal_id, i.sendemail, i.totallines, i.updated AS c_invoice_updated, i.updatedby AS c_invoice_updatedby, i.user1_id, i.user2_id
FROM c_payselectionline psl
JOIN c_invoice i ON psl.c_invoice_id = i.c_invoice_id
JOIN ad_language l ON l.issystemlanguage = 'Y';

View File

@ -1,28 +1,15 @@
CREATE OR REPLACE VIEW C_PROJECT_DETAILS_V
(AD_CLIENT_ID, AD_ORG_ID, ISACTIVE, CREATED, CREATEDBY,
UPDATED, UPDATEDBY, AD_LANGUAGE, C_PROJECT_ID, C_PROJECTLINE_ID,
LINE, PLANNEDQTY, PLANNEDPRICE, PLANNEDAMT, PLANNEDMARGINAMT,
COMMITTEDAMT, M_PRODUCT_ID, NAME, DESCRIPTION, DOCUMENTNOTE,
UPC, SKU, PRODUCTVALUE, M_PRODUCT_CATEGORY_ID, INVOICEDAMT,
INVOICEDQTY, COMMITTEDQTY)
AS
SELECT pl.AD_Client_ID, pl.AD_Org_ID, pl.IsActive, pl.Created, pl.CreatedBy, pl.Updated, pl.UpdatedBy,
cast('en_US' as varchar2(6)) AS AD_Language,
pj.C_Project_ID, pl.C_ProjectLine_ID,
pl.Line,
pl.PlannedQty, pl.PlannedPrice, pl.PlannedAmt, pl.PlannedMarginAmt,
pl.CommittedAmt,
pl.M_Product_ID,
COALESCE(p.Name, pl.Description) AS Name, -- main line
CASE WHEN p.Name IS NOT NULL THEN pl.Description END AS Description, -- second line
p.DocumentNote, -- third line
p.UPC, p.SKU, p.Value AS ProductValue,
pl.M_Product_Category_ID,
pl.InvoicedAmt, pl.InvoicedQty, pl.CommittedQty
FROM C_ProjectLine pl
INNER JOIN C_Project pj ON (pl.C_Project_ID=pj.C_Project_ID)
LEFT OUTER JOIN M_Product p ON (pl.M_Product_ID=p.M_Product_ID)
WHERE pl.IsPrinted='Y';
DROP VIEW c_project_details_v;
CREATE OR REPLACE VIEW c_project_details_v AS
SELECT pl.ad_client_id, pl.ad_org_id, pl.isactive, pl.created, pl.createdby, pl.updated, pl.updatedby,
'en_US' AS ad_language,
pj.c_project_id, pl.c_projectline_id, pl.line, pl.plannedqty, pl.plannedprice, pl.plannedamt, pl.plannedmarginamt, pl.committedamt, pl.m_product_id, COALESCE(p.name, pl.description) AS name,
CASE
WHEN p.name IS NOT NULL THEN pl.description
ELSE NULL
END AS description, p.documentnote, p.upc, p.sku, p.value AS productvalue, pl.m_product_category_id, pl.invoicedamt, pl.invoicedqty, pl.committedqty, pl.c_order_id, pl.c_orderpo_id, pl.c_projectissue_id, pl.c_projectphase_id, pl.c_projecttask_id, pl.dopricing, pl.isprinted, pl.processed AS c_projectline_processed, pj.ad_org_id AS c_project_ad_org_id, pj.ad_user_id, pj.c_bpartner_id, pj.c_bpartner_location_id, pj.c_bpartnersr_id, pj.c_campaign_id, pj.c_currency_id, pj.committedamt AS c_project_committedamt, pj.committedqty AS c_project_committedqty, pj.copyfrom AS c_project_copyfrom, pj.c_paymentterm_id, pj.c_phase_id, pj.c_projecttype_id, pj.created AS c_project_created, pj.createdby AS c_project_createdby, pj.datecontract, pj.datefinish, pj.description AS c_project_description, pj.generateto, pj.invoicedamt AS c_project_invoicedamt, pj.invoicedqty AS c_project_invoicedqty, pj.isactive AS c_project_isactive, pj.iscommitceiling, pj.iscommitment, pj.issummary AS c_project_issummary, pj.m_pricelist_version_id, pj.m_warehouse_id, pj.name AS c_project_name, pj.note AS c_project_note, pj.plannedamt AS c_project_plannedamt, pj.plannedmarginamt AS c_project_plannedmarginamt, pj.plannedqty AS c_project_plannedqty, pj.poreference, pj.processed AS c_project_processed, pj.processing AS c_project_processing, pj.projectbalanceamt, pj.projectcategory, pj.projectlinelevel, pj.projinvoicerule, pj.salesrep_id AS c_project_salesrep_id, pj.updated AS c_project_updated, pj.updatedby AS c_project_updatedby, pj.value AS c_project_value, p.ad_org_id AS m_product_ad_org_id, p.classification, p.copyfrom AS m_product_copyfrom, p.created AS m_product_created, p.createdby AS m_product_createdby, p.c_revenuerecognition_id, p.c_subscriptiontype_id, p.c_taxcategory_id, p.c_uom_id, p.description AS m_product_description, p.descriptionurl, p.discontinued, p.discontinuedat, p.group1, p.group2, p.guaranteedays, p.guaranteedaysmin, p.help, p.imageurl, p.isactive AS m_product_isactive, p.isdropship, p.isexcludeautodelivery, p.isinvoiceprintdetails, p.ispicklistprintdetails, p.ispurchased, p.isselfservice, p.issold, p.isstocked, p.issummary AS m_product_issummary, p.isverified, p.iswebstorefeatured, p.lowlevel, p.m_attributeset_id, p.m_attributesetinstance_id, p.m_freightcategory_id, p.m_locator_id, p.m_product_category_id AS m_product_m_prod_category_id, p.m_product_id AS m_product_m_product_id, p.processing AS m_product_processing, p.producttype, p.r_mailtext_id, p.salesrep_id AS m_product_salesrep_id, p.s_expensetype_id, p.shelfdepth, p.shelfheight, p.shelfwidth, p.s_resource_id, p.unitsperpack, p.unitsperpallet, p.updated AS m_product_updated, p.updatedby AS m_product_updatedby, p.versionno, p.volume, p.weight
FROM c_projectline pl
JOIN c_project pj ON pl.c_project_id = pj.c_project_id
LEFT JOIN m_product p ON pl.m_product_id = p.m_product_id
WHERE pl.isprinted = 'Y';

View File

@ -1,29 +1,15 @@
CREATE OR REPLACE VIEW C_PROJECT_DETAILS_VT
(AD_CLIENT_ID, AD_ORG_ID, ISACTIVE, CREATED, CREATEDBY,
UPDATED, UPDATEDBY, AD_LANGUAGE, C_PROJECT_ID, C_PROJECTLINE_ID,
LINE, PLANNEDQTY, PLANNEDPRICE, PLANNEDAMT, PLANNEDMARGINAMT,
COMMITTEDAMT, M_PRODUCT_ID, NAME, DESCRIPTION, DOCUMENTNOTE,
UPC, SKU, PRODUCTVALUE, M_PRODUCT_CATEGORY_ID, INVOICEDAMT,
INVOICEDQTY, COMMITTEDQTY)
AS
SELECT pl.AD_Client_ID, pl.AD_Org_ID, pl.IsActive, pl.Created, pl.CreatedBy, pl.Updated, pl.UpdatedBy,
l.AD_Language,
pj.C_Project_ID, pl.C_ProjectLine_ID,
pl.Line,
pl.PlannedQty, pl.PlannedPrice, pl.PlannedAmt, pl.PlannedMarginAmt,
pl.CommittedAmt,
pl.M_Product_ID,
COALESCE(p.Name, pl.Description) AS Name, -- main line
CASE WHEN p.Name IS NOT NULL THEN pl.Description END AS Description, -- second line
p.DocumentNote, -- third line
p.UPC, p.SKU, p.Value AS ProductValue,
pl.M_Product_Category_ID,
pl.InvoicedAmt, pl.InvoicedQty, pl.CommittedQty
FROM C_ProjectLine pl
INNER JOIN C_Project pj ON (pl.C_Project_ID=pj.C_Project_ID)
LEFT OUTER JOIN M_Product p ON (pl.M_Product_ID=p.M_Product_ID)
INNER JOIN AD_Language l ON (l.IsSystemLanguage='Y')
WHERE pl.IsPrinted='Y';
DROP VIEW c_project_details_vt;
CREATE OR REPLACE VIEW c_project_details_vt AS
SELECT pl.ad_client_id, pl.ad_org_id, pl.isactive, pl.created, pl.createdby, pl.updated, pl.updatedby, l.ad_language, pj.c_project_id, pl.c_projectline_id, pl.line, pl.plannedqty, pl.plannedprice, pl.plannedamt, pl.plannedmarginamt, pl.committedamt, pl.m_product_id, COALESCE(pt.name, pl.description) AS name,
CASE
WHEN pt.name IS NOT NULL THEN pl.description
ELSE NULL
END AS description, pt.documentnote, p.upc, p.sku, p.value AS productvalue, pl.m_product_category_id, pl.invoicedamt, pl.invoicedqty, pl.committedqty, pl.c_order_id, pl.c_orderpo_id, pl.c_projectissue_id, pl.c_projectphase_id, pl.c_projecttask_id, pl.dopricing, pl.isprinted, pl.processed AS c_projectline_processed, pj.ad_org_id AS c_project_ad_org_id, pj.ad_user_id, pj.c_bpartner_id, pj.c_bpartner_location_id, pj.c_bpartnersr_id, pj.c_campaign_id, pj.c_currency_id, pj.committedamt AS c_project_committedamt, pj.committedqty AS c_project_committedqty, pj.copyfrom AS c_project_copyfrom, pj.c_paymentterm_id, pj.c_phase_id, pj.c_projecttype_id, pj.created AS c_project_created, pj.createdby AS c_project_createdby, pj.datecontract, pj.datefinish, pj.description AS c_project_description, pj.generateto, pj.invoicedamt AS c_project_invoicedamt, pj.invoicedqty AS c_project_invoicedqty, pj.isactive AS c_project_isactive, pj.iscommitceiling, pj.iscommitment, pj.issummary AS c_project_issummary, pj.m_pricelist_version_id, pj.m_warehouse_id, pj.name AS c_project_name, pj.note AS c_project_note, pj.plannedamt AS c_project_plannedamt, pj.plannedmarginamt AS c_project_plannedmarginamt, pj.plannedqty AS c_project_plannedqty, pj.poreference, pj.processed AS c_project_processed, pj.processing AS c_project_processing, pj.projectbalanceamt, pj.projectcategory, pj.projectlinelevel, pj.projinvoicerule, pj.salesrep_id AS c_project_salesrep_id, pj.updated AS c_project_updated, pj.updatedby AS c_project_updatedby, pj.value AS c_project_value, pt.ad_org_id AS m_product_ad_org_id, p.classification, p.copyfrom AS m_product_copyfrom, pt.created AS m_product_created, pt.createdby AS m_product_createdby, p.c_revenuerecognition_id, p.c_subscriptiontype_id, p.c_taxcategory_id, p.c_uom_id, pt.description AS m_product_description, p.descriptionurl, p.discontinued, p.discontinuedat, p.group1, p.group2, p.guaranteedays, p.guaranteedaysmin, p.help, p.imageurl, pt.isactive AS m_product_isactive, p.isdropship, p.isexcludeautodelivery, p.isinvoiceprintdetails, p.ispicklistprintdetails, p.ispurchased, p.isselfservice, p.issold, p.isstocked, p.issummary AS m_product_issummary, p.isverified, p.iswebstorefeatured, p.lowlevel, p.m_attributeset_id, p.m_attributesetinstance_id, p.m_freightcategory_id, p.m_locator_id, p.m_product_category_id AS m_product_m_prod_category_id, p.m_product_id AS m_product_m_product_id, p.processing AS m_product_processing, p.producttype, p.r_mailtext_id, p.salesrep_id AS m_product_salesrep_id, p.s_expensetype_id, p.shelfdepth, p.shelfheight, p.shelfwidth, p.s_resource_id, p.unitsperpack, p.unitsperpallet, p.updated AS m_product_updated, p.updatedby AS m_product_updatedby, p.versionno, p.volume, p.weight
FROM c_projectline pl
JOIN c_project pj ON pl.c_project_id = pj.c_project_id
LEFT JOIN m_product p ON pl.m_product_id = p.m_product_id
LEFT JOIN m_product_trl pt ON pl.m_product_id = pt.m_product_id
JOIN ad_language l ON l.issystemlanguage = 'Y'
WHERE pl.isprinted = 'Y';

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1,71 +1,50 @@
CREATE OR REPLACE VIEW M_INOUT_LINE_V
(AD_CLIENT_ID, AD_ORG_ID, ISACTIVE, CREATED, CREATEDBY,
UPDATED, UPDATEDBY, AD_LANGUAGE, M_INOUT_ID, M_INOUTLINE_ID,
LINE, M_PRODUCT_ID, MOVEMENTQTY, QTYENTERED, UOMSYMBOL,
QTYORDERED, QTYDELIVERED, QTYBACKORDERED, NAME, DESCRIPTION,
DOCUMENTNOTE, UPC, SKU, PRODUCTVALUE, M_LOCATOR_ID,
M_WAREHOUSE_ID, X, Y, Z, M_ATTRIBUTESETINSTANCE_ID,
M_ATTRIBUTESET_ID, SERNO, LOT, M_LOT_ID, GUARANTEEDATE,
PRODUCTDESCRIPTION, IMAGEURL, C_CAMPAIGN_ID, C_PROJECT_ID, C_ACTIVITY_ID,
C_PROJECTPHASE_ID, C_PROJECTTASK_ID)
AS
SELECT iol.AD_Client_ID, iol.AD_Org_ID, iol.IsActive, iol.Created, iol.CreatedBy, iol.Updated, iol.UpdatedBy,
'en_US' AS AD_LANGUAGE,
iol.M_InOut_ID, iol.M_InOutLine_ID,
iol.Line, p.M_Product_ID,
CASE WHEN iol.MovementQty<>0 OR iol.M_Product_ID IS NOT NULL THEN iol.MovementQty END AS MovementQty,
CASE WHEN iol.QtyEntered<>0 OR iol.M_Product_ID IS NOT NULL THEN iol.QtyEntered END AS QtyEntered,
CASE WHEN iol.MovementQty<>0 OR iol.M_Product_ID IS NOT NULL THEN uom.UOMSymbol END AS UOMSymbol,
ol.QtyOrdered, ol.QtyDelivered,
CASE WHEN iol.MovementQty<>0 OR iol.M_Product_ID IS NOT NULL THEN ol.QtyOrdered-ol.QtyDelivered END AS QtyBackOrdered,
COALESCE(p.NAME||Productattribute(iol.M_AttributeSetInstance_ID), c.NAME, iol.Description) AS NAME, -- main line
CASE WHEN COALESCE(c.NAME,p.NAME) IS NOT NULL THEN iol.Description END AS Description, -- second line
p.DocumentNote, -- third line
p.UPC, p.SKU, p.VALUE AS ProductValue,
iol.M_Locator_ID, l.M_Warehouse_ID, l.X, l.Y, l.Z,
iol.M_AttributeSetInstance_ID, asi.M_AttributeSet_ID, asi.SerNo, asi.Lot, asi.M_Lot_ID,asi.GuaranteeDate,
p.Description AS ProductDescription, p.ImageURL,
iol.C_Campaign_ID, iol.C_Project_ID, iol.C_Activity_ID, iol.C_ProjectPhase_ID, iol.C_ProjectTask_ID
FROM M_INOUTLINE iol
INNER JOIN C_UOM uom ON (iol.C_UOM_ID=uom.C_UOM_ID)
LEFT OUTER JOIN M_PRODUCT p ON (iol.M_Product_ID=p.M_Product_ID)
LEFT OUTER JOIN M_ATTRIBUTESETINSTANCE asi ON (iol.M_AttributeSetInstance_ID=asi.M_AttributeSetInstance_ID)
LEFT OUTER JOIN M_LOCATOR l ON (iol.M_Locator_ID=l.M_Locator_ID)
LEFT OUTER JOIN C_ORDERLINE ol ON (iol.C_OrderLine_ID=ol.C_OrderLine_ID)
LEFT OUTER JOIN C_CHARGE c ON (iol.C_Charge_ID=c.C_Charge_ID)
UNION -- BOM lines
SELECT iol.AD_Client_ID, iol.AD_Org_ID, iol.IsActive, iol.Created, iol.CreatedBy, iol.Updated, iol.UpdatedBy,
'en_US' AS AD_LANGUAGE,
iol.M_InOut_ID, iol.M_InOutLine_ID,
iol.Line+(bl.Line/100) AS Line, p.M_Product_ID,
--iol.MovementQty*b.BOMQty AS QtyInvoiced,
CASE WHEN bl.IsQtyPercentage = 'N' THEN iol.MovementQty*bl.QtyBOM ELSE iol.MovementQty*(bl.QtyBatch / 100) END AS QtyInvoiced,
--iol.QtyEntered*b.BOMQty AS QtyEntered,
CASE WHEN bl.IsQtyPercentage = 'N' THEN iol.QtyEntered*bl.QtyBOM ELSE iol.QtyEntered*(bl.QtyBatch / 100) END AS QtyEntered,
uom.UOMSymbol,
NULL, NULL, NULL,
p.NAME, -- main line
b.Description, -- second line
p.DocumentNote, -- third line
p.UPC, p.SKU, p.VALUE AS ProductValue,
iol.M_Locator_ID, l.M_Warehouse_ID, l.X, l.Y, l.Z,
iol.M_AttributeSetInstance_ID, asi.M_AttributeSet_ID, asi.SerNo, asi.Lot, asi.M_Lot_ID,asi.GuaranteeDate,
p.Description AS ProductDescription, p.ImageURL,
iol.C_Campaign_ID, iol.C_Project_ID, iol.C_Activity_ID, iol.C_ProjectPhase_ID, iol.C_ProjectTask_ID
/*FROM M_Product_BOM b -- BOM lines
INNER JOIN M_InOutLine iol ON (b.M_Product_ID=iol.M_Product_ID)
INNER JOIN M_Product bp ON (bp.M_Product_ID=iol.M_Product_ID -- BOM Product
AND bp.IsBOM='Y' AND bp.IsVerified='Y' AND bp.IsPickListPrintDetails='Y')
INNER JOIN M_Product p ON (b.M_ProductBOM_ID=p.M_Product_ID) -- BOM line product
INNER JOIN C_UOM uom ON (p.C_UOM_ID=uom.C_UOM_ID)
LEFT OUTER JOIN M_AttributeSetInstance asi ON (iol.M_AttributeSetInstance_ID=asi.M_AttributeSetInstance_ID)
LEFT OUTER JOIN M_Locator l ON (iol.M_Locator_ID=l.M_Locator_ID)*/
FROM PP_PRODUCT_BOM b -- BOM lines
INNER JOIN M_INOUTLINE iol ON (b.M_Product_ID=iol.M_Product_ID)
INNER JOIN M_PRODUCT bp ON (bp.M_Product_ID=iol.M_Product_ID -- BOM Product
AND bp.IsBOM='Y' AND bp.IsVerified='Y' AND bp.IsPickListPrintDetails='Y')
INNER JOIN PP_PRODUCT_BOMLINE bl ON (bl.PP_Product_BOM_ID=b.PP_Product_BOM_ID)
INNER JOIN M_PRODUCT p ON (bl.M_Product_ID=p.M_Product_ID) -- BOM line product
INNER JOIN C_UOM uom ON (p.C_UOM_ID=uom.C_UOM_ID)
LEFT OUTER JOIN M_ATTRIBUTESETINSTANCE asi ON (iol.M_AttributeSetInstance_ID=asi.M_AttributeSetInstance_ID)
LEFT OUTER JOIN M_LOCATOR l ON (iol.M_Locator_ID=l.M_Locator_ID);
DROP VIEW m_inout_line_v;
CREATE OR REPLACE VIEW m_inout_line_v AS
SELECT iol.ad_client_id, iol.ad_org_id, iol.isactive, iol.created, iol.createdby, iol.updated, iol.updatedby, 'en_US' AS ad_language, iol.m_inout_id, iol.m_inoutline_id, iol.line, p.m_product_id,
CASE
WHEN iol.movementqty <> 0 OR iol.m_product_id IS NOT NULL THEN iol.movementqty
ELSE NULL
END AS movementqty,
CASE
WHEN iol.qtyentered <> 0 OR iol.m_product_id IS NOT NULL THEN iol.qtyentered
ELSE NULL
END AS qtyentered,
CASE
WHEN iol.movementqty <> 0 OR iol.m_product_id IS NOT NULL THEN uom.uomsymbol
ELSE NULL
END AS uomsymbol, ol.qtyordered, ol.qtydelivered,
CASE
WHEN iol.movementqty <> 0 OR iol.m_product_id IS NOT NULL THEN ol.qtyordered - ol.qtydelivered
ELSE NULL
END AS qtybackordered, COALESCE(p.name || productattribute(iol.m_attributesetinstance_id), c.name, iol.description) AS name,
CASE
WHEN COALESCE(c.name, p.name) IS NOT NULL THEN iol.description
ELSE NULL
END AS description, p.documentnote, p.upc, p.sku, p.value AS productvalue, iol.m_locator_id, l.m_warehouse_id, l.x, l.y, l.z, iol.m_attributesetinstance_id, asi.m_attributeset_id, asi.serno, asi.lot, asi.m_lot_id, asi.guaranteedate, p.description AS productdescription, p.imageurl, iol.c_campaign_id, iol.c_project_id, iol.c_activity_id, iol.c_projectphase_id, iol.c_projecttask_id, iol.ad_orgtrx_id, iol.c_charge_id, iol.confirmedqty, iol.c_orderline_id, iol.c_uom_id AS m_inoutline_c_uom_id, iol.isdescription AS m_inoutline_isdescription, iol.isinvoiced, iol.m_rmaline_id, iol.pickedqty, iol.processed AS m_inoutline_processed, iol.ref_inoutline_id, iol.reversalline_id, iol.scrappedqty, iol.targetqty, iol.user1_id AS m_inoutline_user1_id, iol.user2_id AS m_inoutline_user2_id, p.ad_org_id AS m_product_ad_org_id, p.classification, p.copyfrom AS m_product_copyfrom, p.created AS m_product_created, p.createdby AS m_product_createdby, p.c_revenuerecognition_id, p.c_subscriptiontype_id, p.c_taxcategory_id AS m_product_c_taxcategory_id, p.c_uom_id AS m_product_c_uom_id, p.descriptionurl, p.discontinued, p.discontinuedat, p.group1, p.group2, p.guaranteedays, p.guaranteedaysmin, p.help, p.isactive AS m_product_isactive, p.isbom, p.isdropship, p.isexcludeautodelivery, p.isinvoiceprintdetails, p.ispicklistprintdetails, p.ispurchased, p.isselfservice AS m_product_isselfservice, p.issold, p.isstocked, p.issummary AS m_product_issummary, p.isverified, p.iswebstorefeatured, p.lowlevel, p.m_attributeset_id AS m_product_m_attributeset_id, p.m_attributesetinstance_id AS m_product_m_asi_id, p.m_freightcategory_id, p.m_locator_id AS m_product_m_locator_id, p.m_product_category_id AS m_product_m_prod_category_id, p.processing AS m_product_processing, p.producttype, p.r_mailtext_id, p.salesrep_id AS m_product_salesrep_id, p.s_expensetype_id, p.shelfdepth, p.shelfheight, p.shelfwidth, p.s_resource_id AS m_product_s_resource_id, p.unitsperpack, p.unitsperpallet, p.updated AS m_product_updated, p.updatedby AS m_product_updatedby, p.versionno, p.volume, p.weight, uom.ad_org_id AS c_uom_ad_org_id, uom.costingprecision, uom.description AS c_uom_description, uom.isactive AS c_uom_isactive, uom.isdefault AS c_uom_isdefault, uom.name AS c_uom_name, uom.stdprecision, uom.uomtype, uom.x12de355, asi.ad_org_id AS m_asi_ad_org_id, asi.created AS m_asi_created, asi.createdby AS m_asi_createdby, asi.description AS m_asi_description, asi.isactive AS m_asi_isactive, asi.updated AS m_asi_updated, asi.updatedby AS m_asi_updatedby, l.ad_org_id AS m_locator_ad_org_id, l.isactive AS m_locator_isactive, l.isdefault, l.priorityno, l.value AS m_locator_value, ol.ad_org_id AS c_orderline_ad_org_id, ol.ad_orgtrx_id AS c_orderline_ad_orgtrx_id, ol.c_activity_id AS c_orderline_c_activity_id, ol.c_bpartner_id AS c_orderline_c_bpartner_id, ol.c_bpartner_location_id AS c_orderline_c_bp_location_id, ol.c_charge_id AS c_orderline_c_charge_id, ol.c_currency_id AS c_orderline_c_currency_id, ol.c_order_id, ol.c_project_id AS c_orderline_c_project_id, ol.c_projectphase_id AS c_orderline_c_projectphase_id, ol.c_projecttask_id AS c_orderline_c_projecttask_id, ol.created AS c_orderline_created, ol.createdby AS c_orderline_createdby, ol.c_tax_id AS c_orderline_c_tax_id, ol.c_uom_id AS c_orderline_c_uom_id, ol.datedelivered, ol.dateinvoiced, ol.dateordered, ol.datepromised AS c_orderline_datepromised, ol.description AS c_orderline_description, ol.discount, ol.freightamt AS c_orderline_freightamt, ol.isactive AS c_orderline_isactive, ol.isdescription AS c_orderline_isdescription, ol.line AS c_orderline_line, ol.linenetamt, ol.link_orderline_id, ol.m_attributesetinstance_id AS c_orderline_m_asi_id, ol.m_product_id AS c_orderline_m_product_id, ol.m_promotion_id, ol.m_shipper_id AS c_orderline_m_shipper_id, ol.m_warehouse_id AS c_orderline_warehouse_id, ol.priceactual, ol.pricecost, ol.priceentered, ol.pricelimit, ol.pricelist, ol.processed AS c_orderline_processed, ol.qtyentered AS c_orderline_qtyentered, ol.qtyinvoiced, ol.qtylostsales, ol.qtyreserved, ol.ref_orderline_id, ol.rramt, ol.rrstartdate, ol.s_resourceassignment_id, ol.updated AS c_orderline_updated, ol.updatedby AS c_orderline_updatedby, ol.user1_id AS c_orderline_user1_id, ol.user2_id AS c_orderline_user2_id, c.ad_org_id AS c_charge_c_org_id, c.c_bpartner_id AS c_charge_c_bpartner_id, c.c_chargetype_id, c.chargeamt AS c_charge_chargeamt, c.c_taxcategory_id AS c_charge_c_taxcategory_id, c.description AS c_charge_description, c.isactive AS c_charge_isactive, c.issamecurrency, c.issametax, c.istaxincluded AS c_charge_istaxincluded
FROM m_inoutline iol
JOIN c_uom uom ON iol.c_uom_id = uom.c_uom_id
LEFT JOIN m_product p ON iol.m_product_id = p.m_product_id
LEFT JOIN m_attributesetinstance asi ON iol.m_attributesetinstance_id = asi.m_attributesetinstance_id
LEFT JOIN m_locator l ON iol.m_locator_id = l.m_locator_id
LEFT JOIN c_orderline ol ON iol.c_orderline_id = ol.c_orderline_id
LEFT JOIN c_charge c ON iol.c_charge_id = c.c_charge_id
UNION
SELECT iol.ad_client_id, iol.ad_org_id, iol.isactive, iol.created, iol.createdby, iol.updated, iol.updatedby, 'en_US' AS ad_language, iol.m_inout_id, iol.m_inoutline_id, iol.line + bl.line / 100 AS line, p.m_product_id,
CASE
WHEN bl.isqtypercentage = 'N' THEN iol.movementqty * bl.qtybom
ELSE iol.movementqty * (bl.qtybatch / 100)
END AS movementqty,
CASE
WHEN bl.isqtypercentage = 'N' THEN iol.qtyentered * bl.qtybom
ELSE iol.qtyentered * (bl.qtybatch / 100)
END AS qtyentered, uom.uomsymbol, NULL AS qtyordered, NULL AS qtydelivered, NULL AS qtybackordered, p.name, b.description, p.documentnote, p.upc, p.sku, p.value AS productvalue, iol.m_locator_id, l.m_warehouse_id, l.x, l.y, l.z, iol.m_attributesetinstance_id, asi.m_attributeset_id, asi.serno, asi.lot, asi.m_lot_id, asi.guaranteedate, p.description AS productdescription, p.imageurl, iol.c_campaign_id, iol.c_project_id, iol.c_activity_id, iol.c_projectphase_id, iol.c_projecttask_id, iol.ad_orgtrx_id, iol.c_charge_id, iol.confirmedqty, iol.c_orderline_id, iol.c_uom_id AS m_inoutline_c_uom_id, iol.isdescription AS m_inoutline_isdescription, iol.isinvoiced, iol.m_rmaline_id, iol.pickedqty, iol.processed AS m_inoutline_processed, iol.ref_inoutline_id, iol.reversalline_id, iol.scrappedqty, iol.targetqty, iol.user1_id AS m_inoutline_user1_id, iol.user2_id AS m_inoutline_user2_id, p.ad_org_id AS m_product_ad_org_id, p.classification, p.copyfrom AS m_product_copyfrom, p.created AS m_product_created, p.createdby AS m_product_createdby, p.c_revenuerecognition_id, p.c_subscriptiontype_id, p.c_taxcategory_id AS m_product_c_taxcategory_id, p.c_uom_id AS m_product_c_uom_id, p.descriptionurl, p.discontinued, p.discontinuedat, p.group1, p.group2, p.guaranteedays, p.guaranteedaysmin, p.help, p.isactive AS m_product_isactive, p.isbom, p.isdropship, p.isexcludeautodelivery, p.isinvoiceprintdetails, p.ispicklistprintdetails, p.ispurchased, p.isselfservice AS m_product_isselfservice, p.issold, p.isstocked, p.issummary AS m_product_issummary, p.isverified, p.iswebstorefeatured, p.lowlevel, p.m_attributeset_id AS m_product_m_attributeset_id, p.m_attributesetinstance_id AS m_product_m_asi_id, p.m_freightcategory_id, p.m_locator_id AS m_product_m_locator_id, p.m_product_category_id AS m_product_m_prod_category_id, p.processing AS m_product_processing, p.producttype, p.r_mailtext_id, p.salesrep_id AS m_product_salesrep_id, p.s_expensetype_id, p.shelfdepth, p.shelfheight, p.shelfwidth, p.s_resource_id AS m_product_s_resource_id, p.unitsperpack, p.unitsperpallet, p.updated AS m_product_updated, p.updatedby AS m_product_updatedby, p.versionno, p.volume, p.weight, uom.ad_org_id AS c_uom_ad_org_id, uom.costingprecision, uom.description AS c_uom_description, uom.isactive AS c_uom_isactive, uom.isdefault AS c_uom_isdefault, uom.name AS c_uom_name, uom.stdprecision, uom.uomtype, uom.x12de355, asi.ad_org_id AS m_asi_ad_org_id, asi.created AS m_asi_created, asi.createdby AS m_asi_createdby, asi.description AS m_asi_description, asi.isactive AS m_asi_isactive, asi.updated AS m_asi_updated, asi.updatedby AS m_asi_updatedby, l.ad_org_id AS m_locator_ad_org_id, l.isactive AS m_locator_isactive, l.isdefault, l.priorityno, l.value AS m_locator_value, NULL AS c_orderline_ad_org_id, NULL AS c_orderline_ad_orgtrx_id, NULL AS c_orderline_c_activity_id, NULL AS c_orderline_c_bpartner_id, NULL AS c_orderline_c_bp_location_id, NULL AS c_orderline_c_charge_id, NULL AS c_orderline_c_currency_id, NULL AS c_order_id, NULL AS c_orderline_c_project_id, NULL AS c_orderline_c_projectphase_id, NULL AS c_orderline_c_projecttask_id, NULL AS c_orderline_created, NULL AS c_orderline_createdby, NULL AS c_orderline_c_tax_id, NULL AS c_orderline_c_uom_id, NULL AS datedelivered, NULL AS dateinvoiced, NULL AS dateordered, NULL AS c_orderline_datepromised, NULL AS c_orderline_description, NULL AS discount, NULL AS c_orderline_freightamt, NULL AS c_orderline_isactive, NULL AS c_orderline_isdescription, NULL AS c_orderline_line, NULL AS linenetamt, NULL AS link_orderline_id, NULL AS c_orderline_m_asi_id, NULL AS c_orderline_m_product_id, NULL AS m_promotion_id, NULL AS c_orderline_m_shipper_id, NULL AS c_orderline_warehouse_id, NULL AS priceactual, NULL AS pricecost, NULL AS priceentered, NULL AS pricelimit, NULL AS pricelist, NULL AS c_orderline_processed, NULL AS c_orderline_qtyentered, NULL AS qtyinvoiced, NULL AS qtylostsales, NULL AS qtyreserved, NULL AS ref_orderline_id, NULL AS rramt, NULL AS rrstartdate, NULL AS s_resourceassignment_id, NULL AS c_orderline_updated, NULL AS c_orderline_updatedby, NULL AS c_orderline_user1_id, NULL AS c_orderline_user2_id, NULL AS c_charge_c_org_id, NULL AS c_charge_c_bpartner_id, NULL AS c_chargetype_id, NULL AS c_charge_chargeamt, NULL AS c_charge_c_taxcategory_id, NULL AS c_charge_description, NULL AS c_charge_isactive, NULL AS issamecurrency, NULL AS issametax, NULL AS c_charge_istaxincluded
FROM pp_product_bom b
JOIN m_inoutline iol ON b.m_product_id = iol.m_product_id
JOIN m_product bp ON bp.m_product_id = iol.m_product_id AND bp.isbom = 'Y' AND bp.isverified = 'Y' AND bp.ispicklistprintdetails = 'Y'
JOIN pp_product_bomline bl ON bl.pp_product_bom_id = b.pp_product_bom_id
JOIN m_product p ON bl.m_product_id = p.m_product_id
JOIN c_uom uom ON p.c_uom_id = uom.c_uom_id
LEFT JOIN m_attributesetinstance asi ON iol.m_attributesetinstance_id = asi.m_attributesetinstance_id
LEFT JOIN m_locator l ON iol.m_locator_id = l.m_locator_id;

View File

@ -1,74 +1,54 @@
CREATE OR REPLACE VIEW M_INOUT_LINE_VT
(AD_CLIENT_ID, AD_ORG_ID, ISACTIVE, CREATED, CREATEDBY,
UPDATED, UPDATEDBY, AD_LANGUAGE, M_INOUT_ID, M_INOUTLINE_ID,
LINE, M_PRODUCT_ID, MOVEMENTQTY, QTYENTERED, UOMSYMBOL,
QTYORDERED, QTYDELIVERED, QTYBACKORDERED, NAME, DESCRIPTION,
DOCUMENTNOTE, UPC, SKU, PRODUCTVALUE, M_LOCATOR_ID,
M_WAREHOUSE_ID, X, Y, Z, M_ATTRIBUTESETINSTANCE_ID,
M_ATTRIBUTESET_ID, SERNO, LOT, M_LOT_ID, GUARANTEEDATE,
PRODUCTDESCRIPTION, IMAGEURL, C_CAMPAIGN_ID, C_PROJECT_ID, C_ACTIVITY_ID,
C_PROJECTPHASE_ID, C_PROJECTTASK_ID)
AS
SELECT iol.AD_Client_ID, iol.AD_Org_ID, iol.IsActive, iol.Created, iol.CreatedBy, iol.Updated, iol.UpdatedBy,
uom.AD_Language,
iol.M_InOut_ID, iol.M_InOutLine_ID,
iol.Line, p.M_Product_ID,
CASE WHEN iol.MovementQty<>0 OR iol.M_Product_ID IS NOT NULL THEN iol.MovementQty END AS MovementQty,
CASE WHEN iol.QtyEntered<>0 OR iol.M_Product_ID IS NOT NULL THEN iol.QtyEntered END AS QtyEntered,
CASE WHEN iol.MovementQty<>0 OR iol.M_Product_ID IS NOT NULL THEN uom.UOMSymbol END AS UOMSymbol,
ol.QtyOrdered, ol.QtyDelivered,
CASE WHEN iol.MovementQty<>0 OR iol.M_Product_ID IS NOT NULL THEN ol.QtyOrdered-ol.QtyDelivered END AS QtyBackOrdered,
COALESCE(COALESCE(pt.Name,p.Name)||productAttribute(iol.M_AttributeSetInstance_ID), c.Name, iol.Description) AS Name, -- main line
CASE WHEN COALESCE(pt.Name,p.Name,c.Name) IS NOT NULL THEN iol.Description END AS Description, -- second line
COALESCE(pt.DocumentNote, p.DocumentNote) AS DocumentNote, -- third line
p.UPC, p.SKU, p.Value AS ProductValue,
iol.M_Locator_ID, l.M_Warehouse_ID, l.X, l.Y, l.Z,
iol.M_AttributeSetInstance_ID, asi.M_AttributeSet_ID, asi.SerNo, asi.Lot, asi.M_Lot_ID,asi.GuaranteeDate,
pt.Description AS ProductDescription, p.ImageURL,
iol.C_Campaign_ID, iol.C_Project_ID, iol.C_Activity_ID, iol.C_ProjectPhase_ID, iol.C_ProjectTask_ID
FROM M_InOutLine iol
INNER JOIN C_UOM_Trl uom ON (iol.C_UOM_ID=uom.C_UOM_ID)
LEFT OUTER JOIN M_Product p ON (iol.M_Product_ID=p.M_Product_ID)
LEFT OUTER JOIN M_Product_Trl pt ON (iol.M_Product_ID=pt.M_Product_ID AND uom.AD_Language=pt.AD_Language)
LEFT OUTER JOIN M_AttributeSetInstance asi ON (iol.M_AttributeSetInstance_ID=asi.M_AttributeSetInstance_ID)
LEFT OUTER JOIN M_Locator l ON (iol.M_Locator_ID=l.M_Locator_ID)
LEFT OUTER JOIN C_OrderLine ol ON (iol.C_OrderLine_ID=ol.C_OrderLine_ID)
LEFT OUTER JOIN C_Charge_Trl c ON (iol.C_Charge_ID=c.C_Charge_ID)
UNION
SELECT iol.AD_Client_ID, iol.AD_Org_ID, iol.IsActive, iol.Created, iol.CreatedBy, iol.Updated, iol.UpdatedBy,
uom.AD_Language,
iol.M_InOut_ID, iol.M_InOutLine_ID,
iol.Line+(bl.Line/100) AS Line, p.M_Product_ID,
--iol.MovementQty*b.BOMQty AS QtyInvoiced,
CASE WHEN bl.IsQtyPercentage = 'N' THEN iol.MovementQty*bl.QtyBOM ELSE iol.MovementQty*(bl.QtyBatch / 100) END AS QtyInvoiced,
--iol.QtyEntered*b.BOMQty AS QtyEntered,
CASE WHEN bl.IsQtyPercentage = 'N' THEN iol.QtyEntered*bl.QtyBOM ELSE iol.QtyEntered*(bl.QtyBatch / 100) END AS QtyEntered,
uom.UOMSymbol,
null, null, null,
COALESCE (pt.Name, p.Name) AS Name, -- main line
b.Description, -- second line
COALESCE (pt.DocumentNote, p.DocumentNote) AS DocumentNote, -- third line
p.UPC, p.SKU, p.Value AS ProductValue,
iol.M_Locator_ID, l.M_Warehouse_ID, l.X, l.Y, l.Z,
iol.M_AttributeSetInstance_ID, asi.M_AttributeSet_ID, asi.SerNo, asi.Lot, asi.M_Lot_ID,asi.GuaranteeDate,
pt.Description AS ProductDescription, p.ImageURL,
iol.C_Campaign_ID, iol.C_Project_ID, iol.C_Activity_ID, iol.C_ProjectPhase_ID, iol.C_ProjectTask_ID
/*FROM M_Product_BOM b -- BOM lines
INNER JOIN M_InOutLine iol ON (b.M_Product_ID=iol.M_Product_ID)
INNER JOIN M_Product bp ON (bp.M_Product_ID=iol.M_Product_ID -- BOM Product
AND bp.IsBOM='Y' AND bp.IsVerified='Y' AND bp.IsPickListPrintDetails='Y')
INNER JOIN M_Product p ON (b.M_ProductBOM_ID=p.M_Product_ID) -- BOM line product
INNER JOIN C_UOM_Trl uom ON (p.C_UOM_ID=uom.C_UOM_ID)
INNER JOIN M_Product_Trl pt ON (iol.M_Product_ID=pt.M_Product_ID AND uom.AD_Language=pt.AD_Language)
LEFT OUTER JOIN M_AttributeSetInstance asi ON (iol.M_AttributeSetInstance_ID=asi.M_AttributeSetInstance_ID)
LEFT OUTER JOIN M_Locator l ON (iol.M_Locator_ID=l.M_Locator_ID);*/
FROM PP_Product_BOM b -- BOM lines
INNER JOIN M_InOutLine iol ON (b.M_Product_ID=iol.M_Product_ID)
INNER JOIN M_Product bp ON (bp.M_Product_ID=iol.M_Product_ID -- BOM Product
AND bp.IsBOM='Y' AND bp.IsVerified='Y' AND bp.IsPickListPrintDetails='Y')
INNER JOIN PP_Product_BOMLine bl ON (bl.PP_Product_BOM_ID=b.PP_Product_BOM_ID)
INNER JOIN M_Product p ON (bl.M_Product_ID=p.M_Product_ID) -- BOM line product
INNER JOIN C_UOM_Trl uom ON (p.C_UOM_ID=uom.C_UOM_ID)
INNER JOIN M_Product_Trl pt ON (bl.M_Product_ID=pt.M_Product_ID AND uom.AD_Language=pt.AD_Language)
LEFT OUTER JOIN M_AttributeSetInstance asi ON (iol.M_AttributeSetInstance_ID=asi.M_AttributeSetInstance_ID)
LEFT OUTER JOIN M_Locator l ON (iol.M_Locator_ID=l.M_Locator_ID);
DROP VIEW m_inout_line_vt;
CREATE OR REPLACE VIEW m_inout_line_vt AS
SELECT iol.ad_client_id, iol.ad_org_id, iol.isactive, iol.created, iol.createdby, iol.updated, iol.updatedby, uomt.ad_language, iol.m_inout_id, iol.m_inoutline_id, iol.line, pt.m_product_id,
CASE
WHEN iol.movementqty <> 0 OR iol.m_product_id IS NOT NULL THEN iol.movementqty
ELSE NULL
END AS movementqty,
CASE
WHEN iol.qtyentered <> 0 OR iol.m_product_id IS NOT NULL THEN iol.qtyentered
ELSE NULL
END AS qtyentered,
CASE
WHEN iol.movementqty <> 0 OR iol.m_product_id IS NOT NULL THEN uomt.uomsymbol
ELSE NULL
END AS uomsymbol, ol.qtyordered, ol.qtydelivered,
CASE
WHEN iol.movementqty <> 0 OR iol.m_product_id IS NOT NULL THEN ol.qtyordered - ol.qtydelivered
ELSE NULL
END AS qtybackordered, COALESCE(pt.name || productattribute(iol.m_attributesetinstance_id), ct.name, iol.description) AS name,
CASE
WHEN COALESCE(ct.name, pt.name) IS NOT NULL THEN iol.description
ELSE NULL
END AS description, pt.documentnote, p.upc, p.sku, p.value AS productvalue, iol.m_locator_id, l.m_warehouse_id, l.x, l.y, l.z, iol.m_attributesetinstance_id, asi.m_attributeset_id, asi.serno, asi.lot, asi.m_lot_id, asi.guaranteedate, pt.description AS productdescription, p.imageurl, iol.c_campaign_id, iol.c_project_id, iol.c_activity_id, iol.c_projectphase_id, iol.c_projecttask_id, iol.ad_orgtrx_id, iol.c_charge_id, iol.confirmedqty, iol.c_orderline_id, iol.c_uom_id AS m_inoutline_c_uom_id, iol.isdescription AS m_inoutline_isdescription, iol.isinvoiced, iol.m_rmaline_id, iol.pickedqty, iol.processed AS m_inoutline_processed, iol.ref_inoutline_id, iol.reversalline_id, iol.scrappedqty, iol.targetqty, iol.user1_id AS m_inoutline_user1_id, iol.user2_id AS m_inoutline_user2_id, pt.ad_org_id AS m_product_ad_org_id, p.classification, p.copyfrom AS m_product_copyfrom, pt.created AS m_product_created, pt.createdby AS m_product_createdby, p.c_revenuerecognition_id, p.c_subscriptiontype_id, p.c_taxcategory_id AS m_product_c_taxcategory_id, p.c_uom_id AS m_product_c_uom_id, p.descriptionurl, p.discontinued, p.discontinuedat, p.group1, p.group2, p.guaranteedays, p.guaranteedaysmin, p.help, pt.isactive AS m_product_isactive, p.isbom, p.isdropship, p.isexcludeautodelivery, p.isinvoiceprintdetails, p.ispicklistprintdetails, p.ispurchased, p.isselfservice AS m_product_isselfservice, p.issold, p.isstocked, p.issummary AS m_product_issummary, p.isverified, p.iswebstorefeatured, p.lowlevel, p.m_attributeset_id AS m_product_m_attributeset_id, p.m_attributesetinstance_id AS m_product_m_asi_id, p.m_freightcategory_id, p.m_locator_id AS m_product_m_locator_id, p.m_product_category_id AS m_product_m_prod_category_id, p.processing AS m_product_processing, p.producttype, p.r_mailtext_id, p.salesrep_id AS m_product_salesrep_id, p.s_expensetype_id, p.shelfdepth, p.shelfheight, p.shelfwidth, p.s_resource_id AS m_product_s_resource_id, p.unitsperpack, p.unitsperpallet, p.updated AS m_product_updated, p.updatedby AS m_product_updatedby, p.versionno, p.volume, p.weight, uomt.ad_org_id AS c_uom_ad_org_id, uom.costingprecision, uomt.description AS c_uom_description, uomt.isactive AS c_uom_isactive, uom.isdefault AS c_uom_isdefault, uomt.name AS c_uom_name, uom.stdprecision, uom.uomtype, uom.x12de355, asi.ad_org_id AS m_asi_ad_org_id, asi.created AS m_asi_created, asi.createdby AS m_asi_createdby, asi.description AS m_asi_description, asi.isactive AS m_asi_isactive, asi.updated AS m_asi_updated, asi.updatedby AS m_asi_updatedby, l.ad_org_id AS m_locator_ad_org_id, l.isactive AS m_locator_isactive, l.isdefault, l.priorityno, l.value AS m_locator_value, ol.ad_org_id AS c_orderline_ad_org_id, ol.ad_orgtrx_id AS c_orderline_ad_orgtrx_id, ol.c_activity_id AS c_orderline_c_activity_id, ol.c_bpartner_id AS c_orderline_c_bpartner_id, ol.c_bpartner_location_id AS c_orderline_c_bp_location_id, ol.c_charge_id AS c_orderline_c_charge_id, ol.c_currency_id AS c_orderline_c_currency_id, ol.c_order_id, ol.c_project_id AS c_orderline_c_project_id, ol.c_projectphase_id AS c_orderline_c_projectphase_id, ol.c_projecttask_id AS c_orderline_c_projecttask_id, ol.created AS c_orderline_created, ol.createdby AS c_orderline_createdby, ol.c_tax_id AS c_orderline_c_tax_id, ol.c_uom_id AS c_orderline_c_uom_id, ol.datedelivered, ol.dateinvoiced, ol.dateordered, ol.datepromised AS c_orderline_datepromised, ol.description AS c_orderline_description, ol.discount, ol.freightamt AS c_orderline_freightamt, ol.isactive AS c_orderline_isactive, ol.isdescription AS c_orderline_isdescription, ol.line AS c_orderline_line, ol.linenetamt, ol.link_orderline_id, ol.m_attributesetinstance_id AS c_orderline_m_asi_id, ol.m_product_id AS c_orderline_m_product_id, ol.m_promotion_id, ol.m_shipper_id AS c_orderline_m_shipper_id, ol.m_warehouse_id AS c_orderline_warehouse_id, ol.priceactual, ol.pricecost, ol.priceentered, ol.pricelimit, ol.pricelist, ol.processed AS c_orderline_processed, ol.qtyentered AS c_orderline_qtyentered, ol.qtyinvoiced, ol.qtylostsales, ol.qtyreserved, ol.ref_orderline_id, ol.rramt, ol.rrstartdate, ol.s_resourceassignment_id, ol.updated AS c_orderline_updated, ol.updatedby AS c_orderline_updatedby, ol.user1_id AS c_orderline_user1_id, ol.user2_id AS c_orderline_user2_id, ct.ad_org_id AS c_charge_c_org_id, c.c_bpartner_id AS c_charge_c_bpartner_id, c.c_chargetype_id, c.chargeamt AS c_charge_chargeamt, c.c_taxcategory_id AS c_charge_c_taxcategory_id, ct.description AS c_charge_description, ct.isactive AS c_charge_isactive, c.issamecurrency, c.issametax, c.istaxincluded AS c_charge_istaxincluded
FROM m_inoutline iol
JOIN c_uom uom ON iol.c_uom_id = uom.c_uom_id
JOIN c_uom_trl uomt ON iol.c_uom_id = uomt.c_uom_id
LEFT JOIN m_product p ON iol.m_product_id = p.m_product_id
LEFT JOIN m_product_trl pt ON iol.m_product_id = pt.m_product_id AND uomt.ad_language = pt.ad_language
LEFT JOIN m_attributesetinstance asi ON iol.m_attributesetinstance_id = asi.m_attributesetinstance_id
LEFT JOIN m_locator l ON iol.m_locator_id = l.m_locator_id
LEFT JOIN c_orderline ol ON iol.c_orderline_id = ol.c_orderline_id
LEFT JOIN c_charge c ON iol.c_charge_id = c.c_charge_id
LEFT JOIN c_charge_trl ct ON iol.c_charge_id = ct.c_charge_id
UNION
SELECT iol.ad_client_id, iol.ad_org_id, iol.isactive, iol.created, iol.createdby, iol.updated, iol.updatedby, uomt.ad_language, iol.m_inout_id, iol.m_inoutline_id, iol.line + bl.line / 100 AS line, pt.m_product_id,
CASE
WHEN bl.isqtypercentage = 'N' THEN iol.movementqty * bl.qtybom
ELSE iol.movementqty * (bl.qtybatch / 100)
END AS movementqty,
CASE
WHEN bl.isqtypercentage = 'N' THEN iol.qtyentered * bl.qtybom
ELSE iol.qtyentered * (bl.qtybatch / 100)
END AS qtyentered, uomt.uomsymbol, NULL AS qtyordered, NULL AS qtydelivered, NULL AS qtybackordered, pt.name, b.description, pt.documentnote, p.upc, p.sku, p.value AS productvalue, iol.m_locator_id, l.m_warehouse_id, l.x, l.y, l.z, iol.m_attributesetinstance_id, asi.m_attributeset_id, asi.serno, asi.lot, asi.m_lot_id, asi.guaranteedate, pt.description AS productdescription, p.imageurl, iol.c_campaign_id, iol.c_project_id, iol.c_activity_id, iol.c_projectphase_id, iol.c_projecttask_id, iol.ad_orgtrx_id, iol.c_charge_id, iol.confirmedqty, iol.c_orderline_id, iol.c_uom_id AS m_inoutline_c_uom_id, iol.isdescription AS m_inoutline_isdescription, iol.isinvoiced, iol.m_rmaline_id, iol.pickedqty, iol.processed AS m_inoutline_processed, iol.ref_inoutline_id, iol.reversalline_id, iol.scrappedqty, iol.targetqty, iol.user1_id AS m_inoutline_user1_id, iol.user2_id AS m_inoutline_user2_id, pt.ad_org_id AS m_product_ad_org_id, p.classification, p.copyfrom AS m_product_copyfrom, pt.created AS m_product_created, pt.createdby AS m_product_createdby, p.c_revenuerecognition_id, p.c_subscriptiontype_id, p.c_taxcategory_id AS m_product_c_taxcategory_id, p.c_uom_id AS m_product_c_uom_id, p.descriptionurl, p.discontinued, p.discontinuedat, p.group1, p.group2, p.guaranteedays, p.guaranteedaysmin, p.help, pt.isactive AS m_product_isactive, p.isbom, p.isdropship, p.isexcludeautodelivery, p.isinvoiceprintdetails, p.ispicklistprintdetails, p.ispurchased, p.isselfservice AS m_product_isselfservice, p.issold, p.isstocked, p.issummary AS m_product_issummary, p.isverified, p.iswebstorefeatured, p.lowlevel, p.m_attributeset_id AS m_product_m_attributeset_id, p.m_attributesetinstance_id AS m_product_m_asi_id, p.m_freightcategory_id, p.m_locator_id AS m_product_m_locator_id, p.m_product_category_id AS m_product_m_prod_category_id, p.processing AS m_product_processing, p.producttype, p.r_mailtext_id, p.salesrep_id AS m_product_salesrep_id, p.s_expensetype_id, p.shelfdepth, p.shelfheight, p.shelfwidth, p.s_resource_id AS m_product_s_resource_id, p.unitsperpack, p.unitsperpallet, pt.updated AS m_product_updated, pt.updatedby AS m_product_updatedby, p.versionno, p.volume, p.weight, uomt.ad_org_id AS c_uom_ad_org_id, uom.costingprecision, uomt.description AS c_uom_description, uomt.isactive AS c_uom_isactive, uom.isdefault AS c_uom_isdefault, uomt.name AS c_uom_name, uom.stdprecision, uom.uomtype, uom.x12de355, asi.ad_org_id AS m_asi_ad_org_id, asi.created AS m_asi_created, asi.createdby AS m_asi_createdby, asi.description AS m_asi_description, asi.isactive AS m_asi_isactive, asi.updated AS m_asi_updated, asi.updatedby AS m_asi_updatedby, l.ad_org_id AS m_locator_ad_org_id, l.isactive AS m_locator_isactive, l.isdefault, l.priorityno, l.value AS m_locator_value, NULL AS c_orderline_ad_org_id, NULL AS c_orderline_ad_orgtrx_id, NULL AS c_orderline_c_activity_id, NULL AS c_orderline_c_bpartner_id, NULL AS c_orderline_c_bp_location_id, NULL AS c_orderline_c_charge_id, NULL AS c_orderline_c_currency_id, NULL AS c_order_id, NULL AS c_orderline_c_project_id, NULL AS c_orderline_c_projectphase_id, NULL AS c_orderline_c_projecttask_id, NULL AS c_orderline_created, NULL AS c_orderline_createdby, NULL AS c_orderline_c_tax_id, NULL AS c_orderline_c_uom_id, NULL AS datedelivered, NULL AS dateinvoiced, NULL AS dateordered, NULL AS c_orderline_datepromised, NULL AS c_orderline_description, NULL AS discount, NULL AS c_orderline_freightamt, NULL AS c_orderline_isactive, NULL AS c_orderline_isdescription, NULL AS c_orderline_line, NULL AS linenetamt, NULL AS link_orderline_id, NULL AS c_orderline_m_asi_id, NULL AS c_orderline_m_product_id, NULL AS m_promotion_id, NULL AS c_orderline_m_shipper_id, NULL AS c_orderline_warehouse_id, NULL AS priceactual, NULL AS pricecost, NULL AS priceentered, NULL AS pricelimit, NULL AS pricelist, NULL AS c_orderline_processed, NULL AS c_orderline_qtyentered, NULL AS qtyinvoiced, NULL AS qtylostsales, NULL AS qtyreserved, NULL AS ref_orderline_id, NULL AS rramt, NULL AS rrstartdate, NULL AS s_resourceassignment_id, NULL AS c_orderline_updated, NULL AS c_orderline_updatedby, NULL AS c_orderline_user1_id, NULL AS c_orderline_user2_id, NULL AS c_charge_c_org_id, NULL AS c_charge_c_bpartner_id, NULL AS c_chargetype_id, NULL AS c_charge_chargeamt, NULL AS c_charge_c_taxcategory_id, NULL AS c_charge_description, NULL AS c_charge_isactive, NULL AS issamecurrency, NULL AS issametax, NULL AS c_charge_istaxincluded
FROM pp_product_bom b
JOIN m_inoutline iol ON b.m_product_id = iol.m_product_id
JOIN m_product bp ON bp.m_product_id = iol.m_product_id AND bp.isbom = 'Y' AND bp.isverified = 'Y' AND bp.ispicklistprintdetails = 'Y'
JOIN pp_product_bomline bl ON bl.pp_product_bom_id = b.pp_product_bom_id
JOIN m_product p ON bl.m_product_id = p.m_product_id
JOIN c_uom uom ON iol.c_uom_id = uom.c_uom_id
JOIN c_uom_trl uomt ON p.c_uom_id = uomt.c_uom_id
JOIN m_product_trl pt ON bl.m_product_id = pt.m_product_id AND uomt.ad_language = pt.ad_language
LEFT JOIN m_attributesetinstance asi ON iol.m_attributesetinstance_id = asi.m_attributesetinstance_id
LEFT JOIN m_locator l ON iol.m_locator_id = l.m_locator_id;

View File

@ -1,20 +1,7 @@
CREATE OR REPLACE VIEW RV_ALLOCATION
(C_ALLOCATIONHDR_ID, AD_CLIENT_ID, AD_ORG_ID, ISACTIVE, CREATED,
CREATEDBY, UPDATED, UPDATEDBY, DOCUMENTNO, DESCRIPTION,
DATETRX, DATEACCT, C_CURRENCY_ID, APPROVALAMT, ISMANUAL,
DOCSTATUS, DOCACTION, PROCESSED, C_ALLOCATIONLINE_ID, C_INVOICE_ID,
C_BPARTNER_ID, C_ORDER_ID, C_PAYMENT_ID, C_CASHLINE_ID, AMOUNT,
DISCOUNTAMT, WRITEOFFAMT, OVERUNDERAMT)
AS
SELECT h.C_AllocationHdr_ID, h.AD_Client_ID, h.AD_Org_ID,
h.IsActive, h.Created, h.CreatedBy, h.Updated, h.UpdatedBy,
h.DocumentNo, h.Description, h.DateTrx, h.DateAcct,
h.C_Currency_ID, h.ApprovalAmt, h.IsManual, h.DocStatus, h.DocAction, h.Processed,
l.C_AllocationLine_ID,
l.C_Invoice_ID, l.C_BPartner_ID, l.C_Order_ID, l.C_Payment_ID, l.C_CashLine_ID,
l.Amount, l.DiscountAmt, l.WriteOffAmt, l.OverUnderAmt
FROM C_AllocationHdr h
INNER JOIN C_AllocationLine l ON (h.C_AllocationHdr_ID=l.C_AllocationHdr_ID);
DROP VIEW rv_allocation;
CREATE OR REPLACE VIEW rv_allocation AS
SELECT h.c_allocationhdr_id, h.ad_client_id, h.ad_org_id, h.isactive, h.created, h.createdby, h.updated, h.updatedby, h.documentno, h.description, h.datetrx, h.dateacct, h.c_currency_id, h.approvalamt, h.ismanual, h.docstatus, h.docaction, h.processed, l.c_allocationline_id, l.c_invoice_id, l.c_bpartner_id, l.c_order_id, l.c_payment_id, l.c_cashline_id, l.amount, l.discountamt, l.writeoffamt, l.overunderamt, h.isapproved, h.posted, l.ad_org_id AS c_allocationline_ad_org_id, l.created AS c_allocationline_created, l.createdby AS c_allocationline_createdby, l.datetrx AS c_allocationline_datetrx, l.isactive AS c_allocationline_isactive, l.ismanual AS c_allocationline_ismanual, l.updated AS c_allocationline_updated, l.updatedby AS c_allocationline_updatedby
FROM c_allocationhdr h
JOIN c_allocationline l ON h.c_allocationhdr_id = l.c_allocationhdr_id;

View File

@ -1,59 +1,11 @@
CREATE OR REPLACE VIEW RV_BPARTNER
(AD_CLIENT_ID, AD_ORG_ID, ISACTIVE, CREATED, CREATEDBY,
UPDATED, UPDATEDBY, C_BPARTNER_ID, VALUE, NAME,
NAME2, DESCRIPTION, ISSUMMARY, C_BP_GROUP_ID, ISONETIME,
ISPROSPECT, ISVENDOR, ISCUSTOMER, ISEMPLOYEE, ISSALESREP,
REFERENCENO, DUNS, URL, AD_LANGUAGE, TAXID,
ISTAXEXEMPT, C_INVOICESCHEDULE_ID, RATING, SALESVOLUME, NUMBEREMPLOYEES,
NAICS, FIRSTSALE, ACQUSITIONCOST, POTENTIALLIFETIMEVALUE, ACTUALLIFETIMEVALUE,
SHAREOFCUSTOMER, PAYMENTRULE, SO_CREDITLIMIT, SO_CREDITUSED, SO_CREDITAVAILABLE,
C_PAYMENTTERM_ID, M_PRICELIST_ID, M_DISCOUNTSCHEMA_ID, C_DUNNING_ID, ISDISCOUNTPRINTED,
SO_DESCRIPTION, POREFERENCE, PAYMENTRULEPO, PO_PRICELIST_ID, PO_DISCOUNTSCHEMA_ID,
PO_PAYMENTTERM_ID, DOCUMENTCOPIES, C_GREETING_ID, INVOICERULE, DELIVERYRULE,
FREIGHTCOSTRULE, DELIVERYVIARULE, SALESREP_ID, SENDEMAIL, BPARTNER_PARENT_ID,
INVOICE_PRINTFORMAT_ID, SOCREDITSTATUS, SHELFLIFEMINPCT, AD_ORGBP_ID, FLATDISCOUNT,
TOTALOPENBALANCE, AD_USER_ID, CONTACTNAME, CONTACTDESCRIPTION, EMAIL,
SUPERVISOR_ID, EMAILUSER, BPCONTACTGREETING, TITLE, COMMENTS,
PHONE, PHONE2, FAX, LASTCONTACT, LASTRESULT,
BIRTHDAY, AD_ORGTRX_ID, EMAILVERIFY, LDAPUSER, EMAILVERIFYDATE,
NOTIFICATIONTYPE, C_BPARTNER_LOCATION_ID, POSTAL, CITY, ADDRESS1,
ADDRESS2, ADDRESS3, C_REGION_ID, REGIONNAME, C_COUNTRY_ID,
COUNTRYNAME)
AS
SELECT bp.AD_Client_ID, bp.AD_Org_ID,
bp.IsActive, bp.Created, bp.CreatedBy, bp.Updated, bp.UpdatedBy,
bp.C_BPartner_ID, bp.Value, bp.Name, bp.Name2, bp.Description, bp.IsSummary,
bp.C_BP_Group_ID, bp.IsOneTime, bp.IsProspect, bp.IsVendor, bp.IsCustomer, bp.IsEmployee, bp.IsSalesRep,
bp.ReferenceNo, bp.Duns, bp.URL, bp.AD_Language, bp.TaxID, bp.IsTaxExempt,
bp.C_InvoiceSchedule_ID, bp.Rating, bp.SalesVolume, bp.NumberEmployees, bp.NAICS,
bp.FirstSale, bp.AcqusitionCost, bp.PotentialLifeTimeValue, bp.ActualLifeTimeValue,
bp.ShareOfCustomer, bp.PaymentRule,
bp.SO_CreditLimit, bp.SO_CreditUsed, bp.SO_CreditUsed-bp.SO_CreditLimit AS SO_CreditAvailable,
bp.C_PaymentTerm_ID, bp.M_PriceList_ID, bp.M_DiscountSchema_ID, bp.C_Dunning_ID,
bp.IsDiscountPrinted, bp.SO_Description, bp.POReference, PaymentRulePO,
bp.PO_PriceList_ID, bp.PO_DiscountSchema_ID, bp.PO_PaymentTerm_ID,
bp.DocumentCopies, bp.C_Greeting_ID, bp.InvoiceRule, bp.DeliveryRule,
bp.FreightCostRule, bp.DeliveryViaRule, bp.SalesRep_ID,
bp.SendEMail, bp.BPartner_Parent_ID, bp.Invoice_PrintFormat_ID,
bp.SOCreditStatus, bp.ShelfLifeMinPct, bp.AD_OrgBP_ID,
bp.FlatDiscount, bp.TotalOpenBalance,
-- Contact
c.AD_User_ID, c.Name AS ContactName, c.Description AS ContactDescription,
c.EMail, c.Supervisor_ID,
c.EMailUser, c.C_Greeting_ID AS BPContactGreeting,
c.Title, c.Comments, c.Phone, c.Phone2, c.Fax,
c.LastContact, c.LastResult, c.BirthDay, c.AD_OrgTrx_ID,
c.EMailVerify, c.LDAPUser, c.EMailVerifyDate, c.NotificationType,
-- Location
l.C_BPartner_Location_ID, a.Postal, a.City, a.Address1, a.Address2, a.Address3,
a.C_Region_ID, COALESCE(r.Name,a.RegionName) AS RegionName,
a.C_Country_ID, cc.Name AS CountryName
FROM C_BPartner bp
LEFT OUTER JOIN C_BPartner_Location l ON (bp.C_BPartner_ID=l.C_BPartner_ID AND l.IsActive='Y')
LEFT OUTER JOIN AD_User c ON (bp.C_BPartner_ID=c.C_BPartner_ID AND (c.C_BPartner_Location_ID IS NULL OR c.C_BPartner_Location_ID=l.C_BPartner_Location_ID) AND c.IsActive='Y')
LEFT OUTER JOIN C_Location a ON (l.C_Location_ID=a.C_Location_ID)
LEFT OUTER JOIN C_Region r ON (a.C_Region_ID=r.C_Region_ID)
INNER JOIN C_Country cc ON (a.C_Country_ID=cc.C_Country_ID);
DROP VIEW rv_bpartner;
CREATE OR REPLACE VIEW rv_bpartner AS
SELECT bp.ad_client_id, bp.ad_org_id, bp.isactive, bp.created, bp.createdby, bp.updated, bp.updatedby, bp.c_bpartner_id, bp.value, bp.name, bp.name2, bp.description, bp.issummary, bp.c_bp_group_id, bp.isonetime, bp.isprospect, bp.isvendor, bp.iscustomer, bp.isemployee, bp.issalesrep, bp.referenceno, bp.duns, bp.url, bp.ad_language, bp.taxid, bp.istaxexempt, bp.c_invoiceschedule_id, bp.rating, bp.salesvolume, bp.numberemployees, bp.naics, bp.firstsale, bp.acqusitioncost, bp.potentiallifetimevalue, bp.actuallifetimevalue, bp.shareofcustomer, bp.paymentrule, bp.so_creditlimit, bp.so_creditused, bp.so_creditused - bp.so_creditlimit AS so_creditavailable, bp.c_paymentterm_id, bp.m_pricelist_id, bp.m_discountschema_id, bp.c_dunning_id, bp.isdiscountprinted, bp.so_description, bp.poreference, bp.paymentrulepo, bp.po_pricelist_id, bp.po_discountschema_id, bp.po_paymentterm_id, bp.documentcopies, bp.c_greeting_id, bp.invoicerule, bp.deliveryrule, bp.freightcostrule, bp.deliveryviarule, bp.salesrep_id, bp.sendemail, bp.bpartner_parent_id, bp.invoice_printformat_id, bp.socreditstatus, bp.shelflifeminpct, bp.ad_orgbp_id, bp.flatdiscount, bp.totalopenbalance, c.ad_user_id, c.name AS contactname, c.description AS contactdescription, c.email, c.supervisor_id, c.emailuser, c.c_greeting_id AS bpcontactgreeting, c.title, c.comments, c.phone, c.phone2, c.fax, c.lastcontact, c.lastresult, c.birthday, c.ad_orgtrx_id, c.emailverify, c.ldapuser, c.emailverifydate, c.notificationtype, l.c_bpartner_location_id, a.postal, a.city, a.address1, a.address2, a.address3, a.c_region_id, COALESCE(r.name, a.regionname) AS regionname, a.c_country_id, cc.name AS countryname, bp.c_taxgroup_id AS c_bp_c_taxgroup_id, bp.dunninggrace AS c_bp_dunninggrace, bp.ismanufacturer AS c_bp_ismanufacturer, bp.ispotaxexempt AS c_bp_ispotaxexempt, bp.logo_id AS c_bp_logo_id, l.ad_org_id AS c_bp_location_ad_org_id, l.c_bpartner_id AS c_bp_location_c_bpartner_id, l.c_location_id AS c_bp_location_c_location_id, l.created AS c_bp_location_created, l.createdby AS c_bp_location_createdby, l.c_salesregion_id AS c_bp_location_salesregion_id, l.fax AS c_bp_location_fax, l.isactive AS c_bp_location_isactive, l.isbillto AS c_bp_location_isbillto, l.isdn AS c_bp_location_isdn, l.ispayfrom AS c_bp_location_ispayfrom, l.isremitto AS c_bp_location_isremitto, l.isshipto AS c_bp_location_isshipto, l.name AS c_bp_location_name, l.phone AS c_bp_location_phone, l.phone2 AS c_bp_location_phone2, l.updated AS c_bp_location_updated, l.updatedby AS c_bp_location_updatedby, c.ad_org_id AS ad_user_ad_org_id, c.c_bpartner_id AS ad_user_c_bpartner_id, c.c_bpartner_location_id AS ad_user_c_bpartner_location_id, c.created AS ad_user_created, c.createdby AS ad_user_createdby, c.isactive AS ad_user_isactive, c.updated AS ad_user_updated, c.updatedby AS ad_user_updatedby, c.value AS ad_user_value, a.address4, a.ad_org_id AS c_location_ad_org_id, a.c_city_id, a.c_location_id, a.created AS c_location_created, a.createdby AS c_location_createdby, a.isactive AS c_location_isactive, a.postal_add, a.updated AS c_location_updated, a.updatedby AS c_location_updatedby, r.ad_org_id AS c_region_ad_org_id, r.c_country_id AS c_region_c_country_id, r.description AS c_region_description, r.isactive AS c_region_isactive, r.isdefault, cc.ad_language AS c_country_ad_language, cc.c_currency_id AS c_country_c_currency_id, cc.countrycode, cc.description AS c_country_description, cc.isactive AS c_country_isactive
FROM c_bpartner bp
LEFT JOIN c_bpartner_location l ON bp.c_bpartner_id = l.c_bpartner_id AND l.isactive = 'Y'
LEFT JOIN ad_user c ON bp.c_bpartner_id = c.c_bpartner_id AND (c.c_bpartner_location_id IS NULL OR c.c_bpartner_location_id = l.c_bpartner_location_id) AND c.isactive = 'Y'
LEFT JOIN c_location a ON l.c_location_id = a.c_location_id
LEFT JOIN c_region r ON a.c_region_id = r.c_region_id
JOIN c_country cc ON a.c_country_id = cc.c_country_id;

View File

@ -1,31 +1,12 @@
CREATE OR REPLACE VIEW RV_BPARTNEROPEN
(AD_CLIENT_ID, AD_ORG_ID, ISACTIVE, CREATED, CREATEDBY,
UPDATED, UPDATEDBY, C_BPARTNER_ID, C_CURRENCY_ID, AMT,
OPENAMT, DATEDOC, DAYSDUE, C_CAMPAIGN_ID, C_PROJECT_ID,
C_ACTIVITY_ID)
AS
SELECT i.AD_Client_ID,i.AD_Org_ID, i.IsActive, i.Created,i.CreatedBy,i.Updated,i.UpdatedBy,
i.C_BPartner_ID, i.C_Currency_ID,
i.GrandTotal*i.MultiplierAP AS Amt,
invoiceOpen (i.C_Invoice_ID, i.C_InvoicePaySchedule_ID)*MultiplierAP AS OpenAmt,
i.DateInvoiced AS DateDoc,
COALESCE(daysBetween(getdate(),ips.DueDate), paymentTermDueDays(C_PaymentTerm_ID,DateInvoiced,getdate())) AS DaysDue,
i.C_Campaign_ID, i.C_Project_ID, i.C_Activity_ID
FROM C_Invoice_v i
LEFT OUTER JOIN C_InvoicePaySchedule ips ON (i.C_InvoicePaySchedule_ID=ips.C_InvoicePaySchedule_ID)
WHERE IsPaid='N'
AND DocStatus IN ('CO','CL')
UNION
SELECT p.AD_Client_ID,p.AD_Org_ID, p.IsActive, p.Created,p.CreatedBy,p.Updated,p.UpdatedBy,
p.C_BPartner_ID, p.C_Currency_ID,
p.PayAmt*MultiplierAP*-1 AS Amt,
paymentAvailable(p.C_Payment_ID)*p.MultiplierAP*-1 AS OpenAmt,
p.DateTrx AS DateDoc,
null,
p.C_Campaign_ID, p.C_Project_ID, p.C_Activity_ID
FROM C_Payment_v p
WHERE p.IsAllocated='N' AND p.C_BPartner_ID IS NOT NULL
AND p.DocStatus IN ('CO','CL');
DROP VIEW rv_bpartneropen;
CREATE OR REPLACE VIEW rv_bpartneropen AS
SELECT i.ad_client_id, i.ad_org_id, i.isactive, i.created, i.createdby, i.updated, i.updatedby, i.c_bpartner_id, i.c_currency_id, i.grandtotal * i.multiplierap AS amt, invoiceopen(i.c_invoice_id, i.c_invoicepayschedule_id) * i.multiplierap AS openamt, i.dateinvoiced AS datedoc, COALESCE(daysbetween(getdate(), ips.duedate), paymenttermduedays(i.c_paymentterm_id, i.dateinvoiced, getdate())) AS daysdue, i.c_campaign_id, i.c_project_id, i.c_activity_id, i.ad_orgtrx_id, i.c_charge_id, i.c_conversiontype_id, i.c_doctype_id, i.chargeamt, i.c_invoice_id, i.c_order_id, i.c_payment_id, i.dateacct, i.description, i.docstatus, i.documentno, i.isapproved, i.isselfservice, i.posted, i.processedon, i.reversal_id
FROM c_invoice_v i
LEFT JOIN c_invoicepayschedule ips ON i.c_invoicepayschedule_id = ips.c_invoicepayschedule_id
WHERE i.ispaid = 'N' AND i.docstatus IN ('CO', 'CL')
UNION
SELECT p.ad_client_id, p.ad_org_id, p.isactive, p.created, p.createdby, p.updated, p.updatedby, p.c_bpartner_id, p.c_currency_id, p.payamt * p.multiplierap * (-1) AS amt, paymentavailable(p.c_payment_id) * p.multiplierap * (-1) AS openamt, p.datetrx AS datedoc, NULL AS daysdue, p.c_campaign_id, p.c_project_id, p.c_activity_id, p.ad_orgtrx_id, p.c_charge_id, p.c_conversiontype_id, p.c_doctype_id, p.chargeamt, p.c_invoice_id, p.c_order_id, p.c_payment_id, p.dateacct, p.description, p.docstatus, p.documentno, p.isapproved, p.isselfservice, p.posted, p.processedon, p.reversal_id
FROM c_payment_v p
WHERE p.isallocated = 'N' AND p.c_bpartner_id IS NOT NULL AND p.docstatus IN ('CO', 'CL');

File diff suppressed because one or more lines are too long

View File

@ -1,22 +1,9 @@
CREATE OR REPLACE VIEW RV_COST
(AD_CLIENT_ID, AD_ORG_ID, ISACTIVE, CREATED, CREATEDBY,
UPDATED, UPDATEDBY, M_PRODUCT_ID, VALUE, NAME,
UPC, ISBOM, PRODUCTTYPE, M_PRODUCT_CATEGORY_ID, M_COSTTYPE_ID,
M_COSTELEMENT_ID, COSTELEMENTTYPE, COSTINGMETHOD, ISCALCULATED, C_ACCTSCHEMA_ID,
C_CURRENCY_ID, CURRENTCOSTPRICE, FUTURECOSTPRICE, DESCRIPTION,
CURRENTCOSTPRICELL, FUTURECOSTPRICELL, ISCOSTFROZEN)
AS
SELECT c.AD_Client_ID, c.AD_Org_ID, c.IsActive, c.Created,c.CreatedBy,c.Updated,c.UpdatedBy,
p.M_Product_ID, p.Value, p.Name, p.UPC, p.IsBOM, p.ProductType, p.M_Product_Category_ID,
c.M_CostType_ID,
ce.M_CostElement_ID, ce.CostElementType, ce.CostingMethod, ce.IsCalculated,
acct.C_AcctSchema_ID, acct.C_Currency_ID,
c.CurrentCostPrice, c.FutureCostPrice, c.Description,
c.CurrentCostPriceLL, c.FutureCostPriceLL, c.IsCostFrozen
FROM M_Cost c
INNER JOIN M_Product p ON (c.M_Product_ID=p.M_Product_ID)
INNER JOIN M_CostElement ce ON (c.M_CostElement_ID=ce.M_CostElement_ID)
INNER JOIN C_AcctSchema acct ON (c.C_AcctSchema_ID=acct.C_AcctSchema_ID);
DROP VIEW rv_cost;
CREATE OR REPLACE VIEW rv_cost AS
SELECT c.ad_client_id, c.ad_org_id, c.isactive, c.created, c.createdby, c.updated, c.updatedby, p.m_product_id, p.value, p.name, p.upc, p.isbom, p.producttype, p.m_product_category_id, c.m_costtype_id, ce.m_costelement_id, ce.costelementtype, ce.costingmethod, ce.iscalculated, acct.c_acctschema_id, acct.c_currency_id, c.currentcostprice, c.futurecostprice, c.description, c.currentcostpricell, c.futurecostpricell, c.iscostfrozen, c.cumulatedamt, c.cumulatedqty, c.currentqty, c.m_attributesetinstance_id, c.percent, p.ad_org_id AS m_product_ad_org_id, p.classification, p.copyfrom AS m_product_copyfrom, p.created AS m_product_created, p.createdby AS m_product_createdby, p.c_revenuerecognition_id, p.c_subscriptiontype_id, p.c_taxcategory_id, p.c_uom_id, p.description AS m_product_description, p.descriptionurl, p.discontinued, p.discontinuedat, p.documentnote, p.group1, p.group2, p.guaranteedays, p.guaranteedaysmin, p.help, p.imageurl, p.isactive AS m_product_isactive, p.isdropship, p.isexcludeautodelivery, p.isinvoiceprintdetails, p.ispicklistprintdetails, p.ispurchased, p.isselfservice, p.issold, p.isstocked, p.issummary AS m_product_issummary, p.isverified, p.iswebstorefeatured, p.lowlevel, p.m_attributeset_id AS m_product_m_attributeset_id, p.m_attributesetinstance_id AS m_product_m_attributesetinsta, p.m_freightcategory_id, p.m_locator_id, p.processing AS m_product_processing, p.r_mailtext_id, p.salesrep_id AS m_product_salesrep_id, p.s_expensetype_id, p.shelfdepth, p.shelfheight, p.shelfwidth, p.sku, p.s_resource_id, p.unitsperpack, p.unitsperpallet, p.updated AS m_product_updated, p.updatedby AS m_product_updatedby, p.versionno, p.volume, p.weight, ce.ad_org_id AS m_costelement_ad_org_id, ce.description AS m_costelement_description, ce.isactive AS m_costelement_isactive, ce.name AS m_costelement_name, acct.ad_org_id AS c_acctschema_ad_org_id, acct.description AS c_acctschema_description, acct.name AS c_acctschema_name
FROM m_cost c
JOIN m_product p ON c.m_product_id = p.m_product_id
JOIN m_costelement ce ON c.m_costelement_id = ce.m_costelement_id
JOIN c_acctschema acct ON c.c_acctschema_id = acct.c_acctschema_id;

View File

@ -1,21 +1,9 @@
CREATE OR REPLACE VIEW RV_COSTDETAIL
(AD_CLIENT_ID, AD_ORG_ID, ISACTIVE, CREATED, CREATEDBY,
UPDATED, UPDATEDBY, M_PRODUCT_ID, VALUE, NAME,
UPC, ISBOM, PRODUCTTYPE, M_PRODUCT_CATEGORY_ID, M_INOUTLINE_ID,
C_INVOICELINE_ID, M_ATTRIBUTESETINSTANCE_ID, M_ATTRIBUTESET_ID, LOT, SERNO,
C_ACCTSCHEMA_ID, C_CURRENCY_ID, AMT, QTY, DESCRIPTION,
PROCESSED)
AS
SELECT c.AD_Client_ID, c.AD_Org_ID, c.IsActive, c.Created,c.CreatedBy,c.Updated,c.UpdatedBy,
p.M_Product_ID, p.Value, p.Name, p.UPC, p.IsBOM, p.ProductType, p.M_Product_Category_ID,
c.M_InOutLine_ID, c.C_InvoiceLine_ID,
asi.M_AttributeSetInstance_ID, asi.M_AttributeSet_ID, asi.Lot, asi.SerNo,
acct.C_AcctSchema_ID, acct.C_Currency_ID,
c.Amt, c.Qty, c.Description, Processed
FROM M_CostDetail c
INNER JOIN M_Product p ON (c.M_Product_ID=p.M_Product_ID)
INNER JOIN C_AcctSchema acct ON (c.C_AcctSchema_ID=acct.C_AcctSchema_ID)
INNER JOIN M_AttributeSetInstance asi ON (c.M_AttributeSetInstance_ID=asi.M_AttributeSetInstance_ID);
DROP VIEW rv_costdetail;
CREATE OR REPLACE VIEW rv_costdetail AS
SELECT c.ad_client_id, c.ad_org_id, c.isactive, c.created, c.createdby, c.updated, c.updatedby, p.m_product_id, p.value, p.name, p.upc, p.isbom, p.producttype, p.m_product_category_id, c.m_inoutline_id, c.c_invoiceline_id, asi.m_attributesetinstance_id, asi.m_attributeset_id, asi.lot, asi.serno, acct.c_acctschema_id, acct.c_currency_id, c.amt, c.qty, c.description, c.processed, c.c_orderline_id, c.c_projectissue_id, c.cumulatedamt, c.cumulatedqty, c.currentcostprice, c.currentqty, c.deltaamt, c.deltaqty, c.issotrx, c.m_costdetail_id, c.m_costelement_id, c.m_inventoryline_id, c.m_movementline_id, c.m_productionline_id, c.pp_cost_collector_id, p.ad_org_id AS m_product_ad_org_id, p.classification, p.copyfrom AS m_product_copyfrom, p.created AS m_product_created, p.createdby AS m_product_createdby, p.c_revenuerecognition_id, p.c_subscriptiontype_id, p.c_taxcategory_id, p.c_uom_id, p.description AS m_product_description, p.descriptionurl, p.discontinued, p.discontinuedat, p.documentnote, p.group1, p.group2, p.guaranteedays, p.guaranteedaysmin, p.help, p.imageurl, p.isactive AS m_product_isactive, p.isdropship, p.isexcludeautodelivery, p.isinvoiceprintdetails, p.ispicklistprintdetails, p.ispurchased, p.isselfservice, p.issold, p.isstocked, p.issummary AS m_product_issummary, p.isverified, p.iswebstorefeatured, p.lowlevel, p.m_attributeset_id AS m_product_m_attributeset_id, p.m_attributesetinstance_id AS m_product_m_asi_id, p.m_freightcategory_id, p.m_locator_id, p.processing AS m_product_processing, p.r_mailtext_id, p.salesrep_id AS m_product_salesrep_id, p.s_expensetype_id, p.shelfdepth, p.shelfheight, p.shelfwidth, p.sku, p.s_resource_id, p.unitsperpack, p.unitsperpallet, p.updated AS m_product_updated, p.updatedby AS m_product_updatedby, p.versionno, p.volume, p.weight, acct.ad_org_id AS c_acctschema_ad_org_id, acct.description AS c_acctschema_description, acct.name AS c_acctschema_name, asi.ad_org_id AS m_asi_ad_org_id, asi.created AS m_asi_created, asi.createdby AS m_asi_createdby, asi.description AS m_asi_description, asi.guaranteedate, asi.isactive AS m_asi_isactive, asi.m_lot_id, asi.updated AS m_asi_updated, asi.updatedby AS m_asi_updatedby
FROM m_costdetail c
JOIN m_product p ON c.m_product_id = p.m_product_id
JOIN c_acctschema acct ON c.c_acctschema_id = acct.c_acctschema_id
JOIN m_attributesetinstance asi ON c.m_attributesetinstance_id = asi.m_attributesetinstance_id;

View File

@ -1,38 +1,24 @@
CREATE OR REPLACE VIEW RV_C_INVOICE
(C_INVOICE_ID, AD_CLIENT_ID, AD_ORG_ID, ISACTIVE, CREATED,
CREATEDBY, UPDATED, UPDATEDBY, ISSOTRX, DOCUMENTNO,
DOCSTATUS, DOCACTION, ISPRINTED, ISDISCOUNTPRINTED, PROCESSING,
PROCESSED, ISTRANSFERRED, ISPAID, C_DOCTYPE_ID, C_DOCTYPETARGET_ID,
C_ORDER_ID, DESCRIPTION, ISAPPROVED, SALESREP_ID, DATEINVOICED,
DATEPRINTED, DATEACCT, C_BPARTNER_ID, C_BPARTNER_LOCATION_ID, AD_USER_ID,
C_BP_GROUP_ID, POREFERENCE, DATEORDERED, C_CURRENCY_ID, C_CONVERSIONTYPE_ID,
PAYMENTRULE, C_PAYMENTTERM_ID, M_PRICELIST_ID, C_CAMPAIGN_ID, C_PROJECT_ID,
C_ACTIVITY_ID, ISPAYSCHEDULEVALID, INVOICECOLLECTIONTYPE, C_COUNTRY_ID, C_REGION_ID,
POSTAL, CITY, C_CHARGE_ID, CHARGEAMT, TOTALLINES,
GRANDTOTAL, MULTIPLIER)
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.IsPrinted, i.IsDiscountPrinted, i.Processing, i.Processed, i.IsTransferred, i.IsPaid,
i.C_DocType_ID, i.C_DocTypeTarget_ID, i.C_Order_ID, i.Description, i.IsApproved,
i.SalesRep_ID, i.DateInvoiced, i.DatePrinted, i.DateAcct,
i.C_BPartner_ID, i.C_BPartner_Location_ID, i.AD_User_ID, b.C_BP_Group_ID,
i.POReference, i.DateOrdered, i.C_Currency_ID, C_ConversionType_ID, i.PaymentRule, i.C_PaymentTerm_ID,
i.M_PriceList_ID, i.C_Campaign_ID, i.C_Project_ID, i.C_Activity_ID,
i.IsPayScheduleValid, i.InvoiceCollectionType,
loc.C_Country_ID, loc.C_Region_ID, loc.Postal, loc.City,
-- Amounts
i.C_Charge_ID,
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
FROM C_Invoice i
INNER JOIN C_DocType d ON (i.C_DocType_ID=d.C_DocType_ID)
INNER JOIN C_BPartner b ON (i.C_BPartner_ID=b.C_BPartner_ID)
INNER JOIN C_BPartner_Location bpl ON (i.C_BPartner_Location_ID=bpl.C_BPartner_Location_ID)
INNER JOIN C_Location loc ON (bpl.C_Location_ID=loc.C_Location_ID);
CREATE OR REPLACE VIEW rv_c_invoice 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.isprinted, i.isdiscountprinted, i.processing, i.processed, i.istransferred, i.ispaid, i.c_doctype_id, i.c_doctypetarget_id, i.c_order_id, i.description, i.isapproved, i.salesrep_id, i.dateinvoiced, i.dateprinted, i.dateacct, i.c_bpartner_id, i.c_bpartner_location_id, i.ad_user_id, b.c_bp_group_id, i.poreference, i.dateordered, i.c_currency_id, i.c_conversiontype_id, i.paymentrule, i.c_paymentterm_id, i.m_pricelist_id, i.c_campaign_id, i.c_project_id, i.c_activity_id, i.ispayschedulevalid, i.invoicecollectiontype, loc.c_country_id, loc.c_region_id, loc.postal, loc.city, i.c_charge_id,
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, i.ad_orgtrx_id AS c_invoice_ad_orgtrx_id, i.c_conversiontype_id AS c_invoice_c_conversiontype_id, i.c_dunninglevel_id, i.c_payment_id, i.dateordered AS c_invoice_dateordered, i.dunninggrace, i.generateto, i.isindispute, i.ispayschedulevalid AS c_invoice_ispayschedulevalid, i.isselfservice AS c_invoice_isselfservice, i.istaxincluded, i.m_rma_id, i.posted, i.processedon, i.ref_invoice_id, i.reversal_id, i.sendemail, i.user1_id, i.user2_id, b.acqusitioncost AS c_bp_acqusitioncost, b.actuallifetimevalue AS c_bp_actuallifetimevalue, b.ad_language AS c_bp_ad_language, b.ad_orgbp_id AS c_bp_ad_orgbp_id, b.ad_org_id AS c_bp_ad_org_id, b.bpartner_parent_id AS c_bp_bpartner_parent_id, b.c_dunning_id AS c_bp_c_dunning_id, b.c_greeting_id AS c_bp_c_greeting_id, b.c_invoiceschedule_id AS c_bp_c_invoiceschedule_id, b.c_paymentterm_id AS c_bp_c_paymentterm_id, b.created AS c_bp_created, b.createdby AS c_bp_createdby, b.c_taxgroup_id AS c_bp_c_taxgroup_id, b.deliveryrule AS c_bp_deliveryrule, b.deliveryviarule AS c_bp_deliveryviarule, b.description AS c_bp_description, b.dunninggrace AS c_bp_dunninggrace, b.duns AS c_bp_duns, b.firstsale AS c_bp_firstsale, b.flatdiscount AS c_bp_flatdiscount, b.freightcostrule AS c_bp_freightcostrule, b.invoicerule AS c_bp_invoicerule, b.isactive AS c_bp_isactive, b.iscustomer AS c_bp_iscustomer, b.isdiscountprinted AS c_bp_isdiscountprinted, b.isemployee AS c_bp_isemployee, b.ismanufacturer AS c_bp_ismanufacturer, b.isonetime AS c_bp_isonetime, b.ispotaxexempt AS c_bp_ispotaxexempt, b.isprospect AS c_bp_isprospect, b.issalesrep AS c_bp_issalesrep, b.issummary AS c_bp_issummary, b.istaxexempt AS c_bp_istaxexempt, b.isvendor AS c_bp_isvendor, b.logo_id AS c_bp_logo_id, b.m_discountschema_id AS c_bp_m_discountschema_id, b.m_pricelist_id AS c_bp_m_pricelist_id, b.naics AS c_bp_naics, b.name AS c_bp_name, b.name2 AS c_bp_name2, b.numberemployees AS c_bp_numberemployees, b.paymentrule AS c_bp_paymentrule, b.paymentrulepo AS c_bp_paymentrulepo, b.po_discountschema_id AS c_bp_po_discountschema_id, b.po_paymentterm_id AS c_bp_po_paymentterm_id, b.po_pricelist_id AS c_bp_po_pricelist_id, b.poreference AS c_bp_poreference, b.potentiallifetimevalue AS c_bp_potentiallifetimevalue, b.rating AS c_bp_rating, b.referenceno AS c_bp_referenceno, b.salesrep_id AS c_bp_salesrep_id, b.salesvolume AS c_bp_salesvolume, b.sendemail AS c_bp_sendemail, b.shareofcustomer AS c_bp_shareofcustomer, b.shelflifeminpct AS c_bp_shelflifeminpct, b.so_creditlimit AS c_bp_so_creditlimit, b.socreditstatus AS c_bp_socreditstatus, b.so_creditused AS c_bp_so_creditused, b.so_description AS c_bp_so_description, b.taxid, b.totalopenbalance AS c_bp_totalopenbalance, b.updated AS c_bp_updated, b.updatedby AS c_bp_updatedby, b.url AS c_bp_url, b.value AS c_bp_value, bpl.ad_org_id AS c_bp_location_ad_org_id, bpl.c_bpartner_id AS c_bp_location_c_bpartner_id, bpl.c_location_id AS c_bp_location_c_location_id, bpl.created AS c_bp_location_created, bpl.createdby AS c_bp_location_createdby, bpl.c_salesregion_id, bpl.fax AS c_bp_location_fax, bpl.isactive AS c_bp_location_isactive, bpl.isbillto, bpl.isdn, bpl.ispayfrom, bpl.isremitto, bpl.isshipto, bpl.name AS c_bp_location_name, bpl.phone AS c_bp_location_phone, bpl.phone2 AS c_bp_location_phone2, bpl.updated AS c_bp_location_updated, bpl.updatedby AS c_bp_location_updatedby, loc.address1, loc.address2, loc.address3, loc.address4, loc.ad_org_id AS c_location_ad_org_id, loc.c_city_id, loc.created AS c_location_created, loc.createdby AS c_location_createdby, loc.isactive AS c_location_isactive, loc.postal_add, loc.regionname, loc.updated AS c_location_updated, loc.updatedby AS c_location_updatedby
FROM c_invoice i
JOIN c_doctype d ON i.c_doctype_id = d.c_doctype_id
JOIN c_bpartner b ON i.c_bpartner_id = b.c_bpartner_id
JOIN c_bpartner_location bpl ON i.c_bpartner_location_id = bpl.c_bpartner_location_id
JOIN c_location loc ON bpl.c_location_id = loc.c_location_id;

View File

@ -1,48 +1,27 @@
CREATE OR REPLACE VIEW RV_C_INVOICELINE
(AD_CLIENT_ID, AD_ORG_ID, ISACTIVE, CREATED, CREATEDBY,
UPDATED, UPDATEDBY, C_INVOICELINE_ID, C_INVOICE_ID, SALESREP_ID,
C_BPARTNER_ID, C_BP_GROUP_ID, M_PRODUCT_ID, M_PRODUCT_CATEGORY_ID, DATEINVOICED,
DATEACCT, ISSOTRX, C_DOCTYPE_ID, DOCSTATUS, ISPAID,
C_CAMPAIGN_ID, C_PROJECT_ID, C_ACTIVITY_ID, C_PROJECTPHASE_ID, C_PROJECTTASK_ID,
QTYINVOICED, QTYENTERED, M_ATTRIBUTESETINSTANCE_ID, PRODUCTATTRIBUTE, M_ATTRIBUTESET_ID,
M_LOT_ID, GUARANTEEDATE, LOT, SERNO, PRICELIST,
PRICEACTUAL, PRICELIMIT, PRICEENTERED, DISCOUNT, MARGIN,
MARGINAMT, LINENETAMT, LINELISTAMT, LINELIMITAMT, LINEDISCOUNTAMT,
LINEOVERLIMITAMT)
AS
SELECT
il.AD_Client_ID, il.AD_Org_ID, il.IsActive, il.Created, il.CreatedBy, il.Updated, il.UpdatedBy,
il.C_InvoiceLine_ID, i.C_Invoice_ID, i.SalesRep_ID,
i.C_BPartner_ID, i.C_BP_Group_ID,
il.M_Product_ID, p.M_Product_Category_ID,
i.DateInvoiced, i.DateAcct, i.IsSOTrx, i.C_DocType_ID, i.DocStatus, i.IsPaid,
il.C_Campaign_ID, il.C_Project_ID, il.C_Activity_ID, il.C_ProjectPhase_ID, il.C_ProjectTask_ID,
-- Qty
il.QtyInvoiced*i.Multiplier AS QtyInvoiced,
il.QtyEntered*i.Multiplier AS QtyEntered,
-- Attributes
il.M_AttributeSetInstance_ID, productAttribute(il.M_AttributeSetInstance_ID) AS ProductAttribute,
pasi.M_AttributeSet_ID, pasi.M_Lot_ID, pasi.GuaranteeDate, pasi.Lot, pasi.SerNo,
-- Item Amounts
il.PriceList, il.PriceActual, il.PriceLimit, il.PriceEntered,
CASE WHEN PriceList=0 THEN 0 ELSE
ROUND((PriceList-PriceActual)/PriceList*100,2) END AS Discount,
CASE WHEN PriceLimit=0 THEN 0 ELSE
ROUND((PriceActual-PriceLimit)/PriceLimit*100,2) END AS Margin,
CASE WHEN PriceLimit=0 THEN 0 ELSE
(PriceActual-PriceLimit)*QtyInvoiced END AS MarginAmt,
-- Line Amounts
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
FROM RV_C_Invoice i
INNER JOIN C_InvoiceLine il ON (i.C_Invoice_ID=il.C_Invoice_ID)
LEFT OUTER JOIN M_Product p ON (il.M_Product_ID=p.M_Product_ID)
LEFT OUTER JOIN M_AttributeSetInstance pasi ON (il.M_AttributeSetInstance_ID=pasi.M_AttributeSetInstance_ID);
CREATE OR REPLACE VIEW rv_c_invoiceline AS
SELECT il.ad_client_id, il.ad_org_id, il.isactive, il.created, il.createdby, il.updated, il.updatedby, il.c_invoiceline_id, i.c_invoice_id, i.salesrep_id, i.c_bpartner_id, i.c_bp_group_id, il.m_product_id, p.m_product_category_id, i.dateinvoiced, i.dateacct, i.issotrx, i.c_doctype_id, i.docstatus, i.ispaid, il.c_campaign_id, il.c_project_id, il.c_activity_id, il.c_projectphase_id, il.c_projecttask_id, il.qtyinvoiced * i.multiplier AS qtyinvoiced, il.qtyentered * i.multiplier AS qtyentered, il.m_attributesetinstance_id, productattribute(il.m_attributesetinstance_id) AS productattribute, pasi.m_attributeset_id, pasi.m_lot_id, pasi.guaranteedate, pasi.lot, pasi.serno, il.pricelist, il.priceactual, il.pricelimit, 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.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 (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.a_processed, il.c_charge_id, il.c_orderline_id, il.c_tax_id, il.c_uom_id AS c_invoiceline_c_uom_id, il.description AS c_invoiceline_description, il.isdescription, il.isprinted, il.line, il.linenetamt AS c_invoiceline_linenetamt, il.linetotalamt, il.m_inoutline_id, il.m_rmaline_id, il.processed, il.ref_invoiceline_id, il.rramt, il.rrstartdate, il.s_resourceassignment_id, il.taxamt, il.user1_id, il.user2_id, p.ad_org_id AS m_product_ad_org_id, p.classification, p.copyfrom AS m_product_copyfrom, p.created AS m_product_created, p.createdby AS m_product_createdby, p.c_revenuerecognition_id, p.c_subscriptiontype_id, p.c_taxcategory_id, p.c_uom_id AS m_productline_c_uom_id, p.description AS m_product_description, p.descriptionurl, p.discontinued, p.discontinuedat, p.documentnote, p.group1, p.group2, p.guaranteedays, p.guaranteedaysmin, p.help, p.imageurl, p.isactive AS m_product_isactive, p.isdropship, p.isexcludeautodelivery, p.isinvoiceprintdetails, p.ispicklistprintdetails, p.ispurchased, p.isselfservice, p.issold, p.isstocked, p.issummary AS m_product_issummary, p.isverified, p.iswebstorefeatured, p.lowlevel, p.m_attributeset_id AS m_product_m_attributeset_id, p.m_freightcategory_id, p.m_locator_id, p.m_product_id AS m_product_m_product_id, p.processing AS m_product_processing, p.producttype, p.r_mailtext_id, p.salesrep_id AS m_product_salesrep_id, p.s_expensetype_id, p.shelfdepth, p.shelfheight, p.shelfwidth, p.sku, p.s_resource_id, p.unitsperpack, p.unitsperpallet, p.updated AS m_product_updated, p.updatedby AS m_product_updatedby, p.versionno, p.volume, p.weight, pasi.ad_org_id AS m_asi_ad_org_id, pasi.created AS m_attributesetinstance_created, pasi.createdby AS m_asi_createdby, pasi.description AS m_asi_description, pasi.isactive AS m_attributesetinstance_isacti, pasi.serno AS m_attributesetinstance_serno, pasi.updated AS m_attributesetinstance_updated, pasi.updatedby AS m_asi_updatedby
FROM rv_c_invoice i
JOIN c_invoiceline il ON i.c_invoice_id = il.c_invoice_id
LEFT JOIN m_product p ON il.m_product_id = p.m_product_id
LEFT JOIN m_attributesetinstance pasi ON il.m_attributesetinstance_id = pasi.m_attributesetinstance_id;

View File

@ -1,23 +1,25 @@
CREATE OR REPLACE VIEW RV_C_INVOICETAX
(AD_CLIENT_ID, AD_ORG_ID, ISACTIVE, CREATED, CREATEDBY,
UPDATED, UPDATEDBY, C_TAX_ID, C_INVOICE_ID, C_DOCTYPE_ID,
C_BPARTNER_ID, TAXID, ISTAXEXEMPT, DATEACCT, DATEINVOICED,
ISSOTRX, DOCUMENTNO, ISPAID, C_CURRENCY_ID, TAXBASEAMT,
TAXAMT, TAXLINETOTAL, MULTIPLIER)
AS
SELECT
i.AD_Client_ID, i.AD_Org_ID, i.IsActive, t.Created, t.CreatedBy, t.Updated, t.UpdatedBy,
t.C_Tax_ID, i.C_Invoice_ID, i.C_DocType_ID,
i.C_BPartner_ID, bp.TaxID, bp.IsTaxExempt,
i.DateAcct, i.DateInvoiced, i.IsSOTrx, i.DocumentNo, i.IsPaid, i.C_Currency_ID,
CASE WHEN charAt(d.DocBaseType,3)='C' THEN t.TaxBaseAmt*-1 ELSE t.TaxBaseAmt END AS TaxBaseAmt,
CASE WHEN charAt(d.DocBaseType,3)='C' THEN t.TaxAmt*-1 ELSE t.TaxAmt END AS TaxAmt,
CASE WHEN charAt(d.DocBaseType,3)='C' THEN (t.TaxBaseAmt + t.TaxAmt)*-1 ELSE (t.TaxBaseAmt + t.TaxAmt) END AS TaxLineTotal,
CASE WHEN charAt(d.DocBaseType,3)='C' THEN -1 ELSE 1 END AS Multiplier
FROM C_InvoiceTax t
INNER JOIN C_Invoice i ON (t.C_Invoice_ID=i.C_Invoice_ID)
INNER JOIN C_DocType d ON (i.C_DocType_ID=d.C_DocType_ID)
INNER JOIN C_BPartner bp ON (i.C_BPartner_ID=bp.C_BPartner_ID);
DROP VIEW rv_c_invoicetax;
CREATE OR REPLACE VIEW rv_c_invoicetax AS
SELECT i.ad_client_id, i.ad_org_id, i.isactive, t.created, t.createdby, t.updated, t.updatedby, t.c_tax_id, i.c_invoice_id, i.c_doctype_id, i.c_bpartner_id, bp.taxid, bp.istaxexempt, i.dateacct, i.dateinvoiced, i.issotrx, i.documentno, i.ispaid, i.c_currency_id,
CASE
WHEN charat(d.docbasetype, 3) = 'C' THEN t.taxbaseamt * (-1)
ELSE t.taxbaseamt
END AS taxbaseamt,
CASE
WHEN charat(d.docbasetype, 3) = 'C' THEN t.taxamt * (-1)
ELSE t.taxamt
END AS taxamt,
CASE
WHEN charat(d.docbasetype, 3) = 'C' THEN (t.taxbaseamt + t.taxamt) * (-1)
ELSE t.taxbaseamt + t.taxamt
END AS taxlinetotal,
CASE
WHEN charat(d.docbasetype, 3) = 'C' THEN (-1)
ELSE 1
END AS multiplier, t.ad_org_id AS c_invoicetax_ad_org_id, t.isactive AS c_invoicetax_isactive, t.istaxincluded AS c_invoicetax_istaxincluded, t.processed AS c_invoicetax_processed, i.ad_orgtrx_id AS c_invoice_ad_orgtrx_id, i.ad_user_id, i.c_bpartner_location_id, i.c_activity_id, i.c_campaign_id, i.c_charge_id, i.c_conversiontype_id, i.c_doctypetarget_id, i.c_dunninglevel_id, i.chargeamt, i.c_order_id, i.c_payment_id, i.c_paymentterm_id AS c_invoice_c_paymentterm_id, i.created AS c_invoice_created, i.createdby AS c_invoice_createdby, i.dateprinted, i.description AS c_invoice_description, i.docaction, i.docstatus, i.dunninggrace, i.generateto, i.invoicecollectiontype, i.isapproved, i.isdiscountprinted, i.isindispute, i.ispayschedulevalid, i.isprinted, i.isselfservice AS c_invoice_isselfservice, i.istaxincluded AS c_invoice_istaxincluded, i.istransferred, i.m_pricelist_id, i.m_rma_id, i.paymentrule, i.poreference AS c_invoice_poreference, i.posted, i.processedon, i.processing, i.ref_invoice_id, i.reversal_id, i.salesrep_id, i.sendemail, i.totallines, i.updated AS c_invoice_updated, i.updatedby AS c_invoice_updatedby, i.user1_id, i.user2_id, bp.acqusitioncost AS c_bp_acqusitioncost, bp.actuallifetimevalue AS c_bp_actuallifetimevalue, bp.ad_language AS c_bp_ad_language, bp.ad_orgbp_id AS c_bp_ad_orgbp_id, bp.ad_org_id AS c_bp_ad_org_id, bp.bpartner_parent_id AS c_bp_bpartner_parent_id, bp.c_bp_group_id AS c_bp_c_bp_group_id, bp.c_dunning_id AS c_bp_c_dunning_id, bp.c_greeting_id AS c_bp_c_greeting_id, bp.c_invoiceschedule_id AS c_bp_c_invoiceschedule_id, bp.c_paymentterm_id AS c_bp_c_paymentterm_id, bp.created AS c_bp_created, bp.createdby AS c_bp_createdby, bp.c_taxgroup_id AS c_bp_c_taxgroup_id, bp.deliveryrule AS c_bp_deliveryrule, bp.deliveryviarule AS c_bp_deliveryviarule, bp.description AS c_bp_description, bp.dunninggrace AS c_bp_dunninggrace, bp.duns, bp.firstsale AS c_bp_firstsale, bp.flatdiscount AS c_bp_flatdiscount, bp.freightcostrule AS c_bp_freightcostrule, bp.invoicerule AS c_bp_invoicerule, bp.isactive AS c_bp_isactive, bp.iscustomer AS c_bp_iscustomer, bp.isdiscountprinted AS c_bp_isdiscountprinted, bp.isemployee AS c_bp_isemployee, bp.ismanufacturer AS c_bp_ismanufacturer, bp.isonetime AS c_bp_isonetime, bp.ispotaxexempt AS c_bp_ispotaxexempt, bp.isprospect AS c_bp_isprospect, bp.issalesrep AS c_bp_issalesrep, bp.issummary AS c_bp_issummary, bp.isvendor, bp.logo_id AS c_bp_logo_id, bp.m_discountschema_id, bp.m_pricelist_id AS c_bp_m_pricelist_id, bp.naics, bp.name AS c_bp_name, bp.name2 AS c_bp_name2, bp.numberemployees, bp.paymentrule AS c_bp_paymentrule, bp.paymentrulepo AS c_bp_paymentrulepo, bp.po_discountschema_id, bp.po_paymentterm_id, bp.po_pricelist_id, bp.poreference AS c_bp_poreference, bp.potentiallifetimevalue, bp.rating AS c_bp_rating, bp.salesrep_id AS c_bp_salesrep_id, bp.salesvolume, bp.sendemail AS c_bp_sendemail, bp.shareofcustomer, bp.shelflifeminpct, bp.so_creditlimit, bp.socreditstatus, bp.so_creditused, bp.so_description, bp.totalopenbalance AS c_bp_totalopenbalance, bp.updated AS c_bp_updated, bp.updatedby AS c_bp_updatedby, bp.url AS c_bp_url, bp.value AS c_bp_value
FROM c_invoicetax t
JOIN c_invoice i ON t.c_invoice_id = i.c_invoice_id
JOIN c_doctype d ON i.c_doctype_id = d.c_doctype_id
JOIN c_bpartner bp ON i.c_bpartner_id = bp.c_bpartner_id;

View File

@ -1,42 +1,12 @@
CREATE OR REPLACE VIEW RV_FACT_ACCT
(AD_CLIENT_ID, AD_ORG_ID, ISACTIVE, CREATED, CREATEDBY,
UPDATED, UPDATEDBY, FACT_ACCT_ID, C_ACCTSCHEMA_ID, ACCOUNT_ID,
DATETRX, DATEACCT, C_PERIOD_ID, AD_TABLE_ID, RECORD_ID,
LINE_ID, GL_CATEGORY_ID, GL_BUDGET_ID, C_TAX_ID, M_LOCATOR_ID,
POSTINGTYPE, C_CURRENCY_ID, AMTSOURCEDR, AMTSOURCECR, AMTSOURCE,
AMTACCTDR, AMTACCTCR, AMTACCT, RATE, C_UOM_ID,
QTY, M_PRODUCT_ID, C_BPARTNER_ID, AD_ORGTRX_ID, C_LOCFROM_ID,
C_LOCTO_ID, C_SALESREGION_ID, C_PROJECT_ID, C_CAMPAIGN_ID, C_ACTIVITY_ID,
USER1_ID, USER2_ID, A_ASSET_ID, DESCRIPTION, ORGVALUE,
ORGNAME, ACCOUNTVALUE, NAME, ACCOUNTTYPE, BPARTNERVALUE,
BPNAME, C_BP_GROUP_ID, PRODUCTVALUE, PRODUCTNAME, UPC,
M_PRODUCT_CATEGORY_ID)
AS
SELECT f.AD_Client_ID, f.AD_Org_ID, f.IsActive,f.Created,f.CreatedBy,f.Updated,f.UpdatedBy,
f.Fact_Acct_ID,
f.C_AcctSchema_ID, f.Account_ID, f.DateTrx, f.DateAcct, f.C_Period_ID,
f.AD_Table_ID, f.Record_ID, f.Line_ID,
f.GL_Category_ID, f.GL_Budget_ID, f.C_Tax_ID, f.M_Locator_ID,
f.PostingType, f.C_Currency_ID,
f.AmtSourceDr, f.AmtSourceCr, (f.AmtSourceDr - f.AmtSourceCr) AS AmtSource,
f.AmtAcctDr, f.AmtAcctCr, (f.AmtAcctDr - f.AmtAcctCr) AS AmtAcct,
CASE WHEN (f.AmtSourceDr - f.AmtSourceCr) = 0 THEN 0 ELSE
(f.AmtAcctDr - f.AmtAcctCr) / (f.AmtSourceDr - f.AmtSourceCr) END AS Rate,
f.C_UOM_ID, f.Qty,
f.M_Product_ID, f.C_BPartner_ID, f.AD_OrgTrx_ID,
f.C_LocFrom_ID, f.C_LocTo_ID, f.C_SalesRegion_ID,
f.C_Project_ID, f.C_Campaign_ID, f.C_Activity_ID,
f.User1_ID, f.User2_ID, f.A_Asset_ID,
f.Description,
o.Value AS OrgValue, o.Name AS OrgName,
ev.Value AS AccountValue, ev.Name, ev.AccountType,
bp.Value AS BPartnerValue, bp.Name AS BPName, bp.C_BP_Group_ID,
p.Value AS ProductValue, p.Name AS ProductName, p.UPC, p.M_Product_Category_ID
FROM Fact_Acct f
INNER JOIN AD_Org o ON (f.AD_Org_ID=o.AD_Org_ID)
INNER JOIN C_ElementValue ev ON (f.Account_ID=ev.C_ElementValue_ID)
LEFT OUTER JOIN C_BPartner bp ON (f.C_BPartner_ID=bp.C_BPartner_ID)
LEFT OUTER JOIN M_Product p ON (f.M_Product_ID=p.M_Product_ID);
CREATE OR REPLACE VIEW rv_fact_acct AS
SELECT f.ad_client_id, f.ad_org_id, f.isactive, f.created, f.createdby, f.updated, f.updatedby, f.fact_acct_id, f.c_acctschema_id, f.account_id, f.datetrx, f.dateacct, f.c_period_id, f.ad_table_id, f.record_id, f.line_id, f.gl_category_id, f.gl_budget_id, f.c_tax_id, f.m_locator_id, f.postingtype, f.c_currency_id, f.amtsourcedr, f.amtsourcecr, f.amtsourcedr - f.amtsourcecr AS amtsource, f.amtacctdr, f.amtacctcr, f.amtacctdr - f.amtacctcr AS amtacct,
CASE
WHEN (f.amtsourcedr - f.amtsourcecr) = 0 THEN 0
ELSE (f.amtacctdr - f.amtacctcr) / (f.amtsourcedr - f.amtsourcecr)
END AS rate, f.c_uom_id, f.qty, f.m_product_id, f.c_bpartner_id, f.ad_orgtrx_id, f.c_locfrom_id, f.c_locto_id, f.c_salesregion_id, f.c_project_id, f.c_campaign_id, f.c_activity_id, f.user1_id, f.user2_id, f.a_asset_id, f.description, o.value AS orgvalue, o.name AS orgname, ev.value AS accountvalue, ev.name, ev.accounttype, bp.value AS bpartnervalue, bp.name AS bpname, bp.c_bp_group_id, p.value AS productvalue, p.name AS productname, p.upc, p.m_product_category_id, f.c_projectphase_id, f.c_projecttask_id, f.c_subacct_id, f.userelement1_id, f.userelement2_id, o.description AS ad_org_description, o.isactive AS ad_org_isactive, ev.ad_org_id AS c_elementvalue_ad_org_id, ev.c_bankaccount_id, ev.c_currency_id AS c_elementvalue_c_currency_id, ev.c_element_id, ev.c_elementvalue_id, ev.description AS c_elementvalue_description, ev.isactive AS c_elementvalue_isactive, ev.isbankaccount, ev.isforeigncurrency, ev.issummary AS c_elementvalue_issummary, bp.acqusitioncost AS c_bp_acqusitioncost, bp.actuallifetimevalue AS c_bp_actuallifetimevalue, bp.ad_language AS c_bp_ad_language, bp.ad_orgbp_id AS c_bp_ad_orgbp_id, bp.ad_org_id AS c_bp_ad_org_id, bp.bpartner_parent_id AS c_bp_bpartner_parent_id, bp.c_dunning_id AS c_bp_c_dunning_id, bp.c_greeting_id AS c_bp_c_greeting_id, bp.c_invoiceschedule_id AS c_bp_c_invoiceschedule_id, bp.c_paymentterm_id AS c_bp_c_paymentterm_id, bp.created AS c_bp_created, bp.createdby AS c_bp_createdby, bp.c_taxgroup_id AS c_bp_c_taxgroup_id, bp.deliveryrule AS c_bp_deliveryrule, bp.deliveryviarule AS c_bp_deliveryviarule, bp.description AS c_bp_description, bp.dunninggrace AS c_bp_dunninggrace, bp.duns, bp.firstsale AS c_bp_firstsale, bp.flatdiscount AS c_bp_flatdiscount, bp.freightcostrule AS c_bp_freightcostrule, bp.invoicerule AS c_bp_invoicerule, bp.isactive AS c_bp_isactive, bp.iscustomer AS c_bp_iscustomer, bp.isdiscountprinted AS c_bp_isdiscountprinted, bp.isemployee AS c_bp_isemployee, bp.ismanufacturer AS c_bp_ismanufacturer, bp.isonetime AS c_bp_isonetime, bp.ispotaxexempt AS c_bp_ispotaxexempt, bp.isprospect AS c_bp_isprospect, bp.issalesrep AS c_bp_issalesrep, bp.issummary AS c_bp_issummary, bp.istaxexempt AS c_bp_istaxexempt, bp.isvendor AS c_bp_isvendor, bp.logo_id AS c_bp_logo_id, bp.m_discountschema_id AS c_bp_m_discountschema_id, bp.m_pricelist_id AS c_bp_m_pricelist_id, bp.naics, bp.name2 AS c_bp_name2, bp.numberemployees AS c_bp_numberemployees, bp.paymentrule AS c_bp_paymentrule, bp.paymentrulepo AS c_bp_paymentrulepo, bp.po_discountschema_id AS c_bp_po_discountschema_id, bp.po_paymentterm_id AS c_bp_po_paymentterm_id, bp.po_pricelist_id AS c_bp_po_pricelist_id, bp.poreference AS c_bp_poreference, bp.potentiallifetimevalue AS c_bp_potentiallifetimevalue, bp.rating AS c_bp_rating, bp.referenceno, bp.salesrep_id AS c_bp_salesrep_id, bp.salesvolume AS c_bp_salesvolume, bp.sendemail AS c_bp_sendemail, bp.shareofcustomer AS c_bp_shareofcustomer, bp.shelflifeminpct AS c_bp_shelflifeminpct, bp.so_creditlimit AS c_bp_so_creditlimit, bp.socreditstatus AS c_bp_socreditstatus, bp.so_creditused AS c_bp_so_creditused, bp.so_description AS c_bp_so_description, bp.taxid, bp.totalopenbalance AS c_bp_totalopenbalance, bp.updated AS c_bp_updated, bp.updatedby AS c_bp_updatedby, bp.url AS c_bp_url, p.ad_org_id AS m_product_ad_org_id, p.classification, p.copyfrom AS m_product_copyfrom, p.created AS m_product_created, p.createdby AS m_product_createdby, p.c_revenuerecognition_id, p.c_subscriptiontype_id, p.c_taxcategory_id, p.c_uom_id AS m_product_c_uom_id, p.description AS m_product_description, p.descriptionurl, p.discontinued, p.discontinuedat, p.documentnote, p.group1, p.group2, p.guaranteedays, p.guaranteedaysmin, p.help, p.imageurl, p.isactive AS m_product_isactive, p.isdropship, p.isexcludeautodelivery, p.isinvoiceprintdetails, p.ispicklistprintdetails, p.ispurchased, p.isselfservice, p.issold, p.isstocked, p.issummary AS m_product_issummary, p.isverified, p.iswebstorefeatured, p.lowlevel, p.m_attributeset_id AS m_product_m_attributeset_id, p.m_attributesetinstance_id AS m_product_m_asi_id, p.m_freightcategory_id, p.m_locator_id AS m_product_m_locator_id, p.processing AS m_product_processing, p.producttype, p.r_mailtext_id, p.salesrep_id AS m_product_salesrep_id, p.s_expensetype_id, p.shelfdepth, p.shelfheight, p.shelfwidth, p.sku, p.s_resource_id, p.unitsperpack, p.unitsperpallet, p.updated AS m_product_updated, p.updatedby AS m_product_updatedby, p.versionno, p.volume, p.weight
FROM fact_acct f
JOIN ad_org o ON f.ad_org_id = o.ad_org_id
JOIN c_elementvalue ev ON f.account_id = ev.c_elementvalue_id
LEFT JOIN c_bpartner bp ON f.c_bpartner_id = bp.c_bpartner_id
LEFT JOIN m_product p ON f.m_product_id = p.m_product_id;

View File

@ -1,47 +1,9 @@
CREATE OR REPLACE VIEW RV_INOUTDETAILS
(AD_CLIENT_ID, AD_ORG_ID, ISACTIVE, CREATED, CREATEDBY,
UPDATED, UPDATEDBY, M_INOUT_ID, ISSOTRX, DOCUMENTNO,
DOCACTION, DOCSTATUS, POSTED, PROCESSED, C_DOCTYPE_ID,
DESCRIPTION, C_ORDER_ID, DATEORDERED, MOVEMENTTYPE, MOVEMENTDATE,
DATEACCT, C_BPARTNER_ID, C_BPARTNER_LOCATION_ID, AD_USER_ID, SALESREP_ID,
M_WAREHOUSE_ID, POREFERENCE, DELIVERYRULE, FREIGHTCOSTRULE, FREIGHTAMT,
DELIVERYVIARULE, M_SHIPPER_ID, PRIORITYRULE, DATEPRINTED, NOPACKAGES,
PICKDATE, SHIPDATE, TRACKINGNO, AD_ORGTRX_ID, C_PROJECT_ID,
C_CAMPAIGN_ID, C_ACTIVITY_ID, USER1_ID, USER2_ID, DATERECEIVED,
ISAPPROVED, ISINDISPUTE, M_INOUTLINE_ID, LINE, LINEDESCRIPTION,
C_ORDERLINE_ID, M_LOCATOR_ID, M_PRODUCT_ID, C_UOM_ID, M_ATTRIBUTESETINSTANCE_ID,
PRODUCTATTRIBUTE, M_ATTRIBUTESET_ID, M_LOT_ID, GUARANTEEDATE, LOT,
SERNO, MOVEMENTQTY, QTYENTERED, ISDESCRIPTION, CONFIRMEDQTY,
PICKEDQTY, SCRAPPEDQTY, TARGETQTY, LOCATORVALUE, X,
Y, Z)
AS
SELECT h.AD_Client_ID, h.AD_Org_ID, l.IsActive, l.Created, l.CreatedBy, l.Updated, l.UpdatedBy,
h.M_InOut_ID,
h.IsSOTrx, h.DocumentNo, h.DocAction, h.DocStatus, h.Posted, h.Processed,
h.C_DocType_ID, h.Description, h.C_Order_ID, h.DateOrdered,
h.MovementType, h.MovementDate, h.DateAcct,
h.C_BPartner_ID, h.C_BPartner_Location_ID, h.AD_User_ID,
h.SalesRep_ID,
h.M_Warehouse_ID,
h.POReference, h.DeliveryRule, h.FreightCostRule, h.FreightAmt,
h.DeliveryViaRule, h.M_Shipper_ID, -- h.C_CHARGE_ID, h.CHARGEAmt,
h.PriorityRule, h.DatePrinted,
h.NoPackages, h.PickDate, h.ShipDate, h.TrackingNo,
h.AD_OrgTrx_ID, h.C_Project_ID, h.C_Campaign_ID, h.C_Activity_ID, h.User1_ID, h.User2_ID,
h.DateReceived, h.IsApproved, h.IsInDispute,
l.M_InOutLine_ID, l.Line, l.Description AS LineDescription,
l.C_OrderLine_ID, l.M_Locator_ID,
l.M_Product_ID, l.C_UOM_ID,
l.M_AttributeSetInstance_ID, productAttribute(l.M_AttributeSetInstance_ID) AS ProductAttribute,
pasi.M_AttributeSet_ID, pasi.M_Lot_ID, pasi.GuaranteeDate, pasi.Lot, pasi.SerNo,
l.MovementQty, l.QtyEntered,
l.IsDescription,
l.ConfirmedQty, l.PickedQty, l.ScrappedQty, l.TargetQty,
loc.Value AS LocatorValue, loc.X, loc.Y, loc.Z
FROM M_InOut h
INNER JOIN M_InOutLine l ON (h.M_InOut_ID=l.M_InOut_ID)
LEFT OUTER JOIN M_Locator loc ON (l.M_Locator_ID=loc.M_Locator_ID)
LEFT OUTER JOIN M_AttributeSetInstance pasi ON (l.M_AttributeSetInstance_ID=pasi.M_AttributeSetInstance_ID);
DROP VIEW rv_inoutdetails;
CREATE OR REPLACE VIEW rv_inoutdetails AS
SELECT h.ad_client_id, h.ad_org_id, l.isactive, l.created, l.createdby, l.updated, l.updatedby, h.m_inout_id, h.issotrx, h.documentno, h.docaction, h.docstatus, h.posted, h.processed, h.c_doctype_id, h.description, h.c_order_id, h.dateordered, h.movementtype, h.movementdate, h.dateacct, h.c_bpartner_id, h.c_bpartner_location_id, h.ad_user_id, h.salesrep_id, h.m_warehouse_id, h.poreference, h.deliveryrule, h.freightcostrule, h.freightamt, h.deliveryviarule, h.m_shipper_id, h.priorityrule, h.dateprinted, h.nopackages, h.pickdate, h.shipdate, h.trackingno, h.ad_orgtrx_id, h.c_project_id, h.c_campaign_id, h.c_activity_id, h.user1_id, h.user2_id, h.datereceived, h.isapproved, h.isindispute, l.m_inoutline_id, l.line, l.description AS linedescription, l.c_orderline_id, l.m_locator_id, l.m_product_id, l.c_uom_id, l.m_attributesetinstance_id, productattribute(l.m_attributesetinstance_id) AS productattribute, pasi.m_attributeset_id, pasi.m_lot_id, pasi.guaranteedate, pasi.lot, pasi.serno, l.movementqty, l.qtyentered, l.isdescription, l.confirmedqty, l.pickedqty, l.scrappedqty, l.targetqty, loc.value AS locatorvalue, loc.x, loc.y, loc.z, h.c_charge_id AS m_inout_c_charge_id, h.chargeamt, h.c_invoice_id AS m_inout_c_invoice_id, h.createconfirm, h.created AS m_inout_created, h.createdby AS m_inout_createdby, h.createfrom, h.createpackage, h.dropship_bpartner_id, h.dropship_location_id, h.dropship_user_id, h.generateto, h.isactive AS m_inout_isactive, h.isdropship, h.isintransit, h.isprinted, h.m_rma_id, h.processedon, h.processing, h.ref_inout_id, h.reversal_id, h.sendemail, h.updated AS m_inout_updated, h.updatedby AS m_inout_updatedby, h.volume, h.weight, l.ad_org_id AS m_inoutline_ad_org_id, l.ad_orgtrx_id AS m_inoutline_ad_orgtrx_id, l.c_activity_id AS m_inoutline_c_activity_id, l.c_campaign_id AS m_inoutline_c_campaign_id, l.c_charge_id AS m_inoutline_c_charge_id, l.c_project_id AS m_inoutline_c_project_id, l.c_projectphase_id, l.c_projecttask_id, l.isinvoiced, l.m_rmaline_id, l.processed AS m_inoutline_processed, l.ref_inoutline_id, l.reversalline_id, l.user1_id AS m_inoutline_user1_id, l.user2_id AS m_inoutline_user2_id, loc.ad_org_id AS m_locator_ad_org_id, loc.isactive AS m_locator_isactive, loc.isdefault, loc.m_warehouse_id AS m_locator_m_warehouse_id, loc.priorityno, pasi.ad_org_id AS m_asi_ad_org_id, pasi.created AS m_asi_created, pasi.createdby AS m_asi_createdby, pasi.description AS m_asi_description, pasi.isactive AS m_asi_isactive, pasi.updated AS m_asi_updated, pasi.updatedby AS m_asi_updatedby
FROM m_inout h
JOIN m_inoutline l ON h.m_inout_id = l.m_inout_id
LEFT JOIN m_locator loc ON l.m_locator_id = loc.m_locator_id
LEFT JOIN m_attributesetinstance pasi ON l.m_attributesetinstance_id = pasi.m_attributesetinstance_id;

View File

@ -1,16 +1,9 @@
CREATE OR REPLACE VIEW RV_M_TRANSACTION
(AD_CLIENT_ID, AD_ORG_ID, MOVEMENTDATE, MOVEMENTQTY, M_PRODUCT_ID,
M_LOCATOR_ID, M_ATTRIBUTESETINSTANCE_ID, M_PRODUCT_CATEGORY_ID, VALUE, C_BPARTNER_ID,
PRICEPO, PRICELASTPO, PRICELIST)
AS
SELECT t.AD_Client_ID,t.AD_Org_ID, t.MovementDate, t.MovementQty,
t.M_Product_ID, t.M_Locator_ID, t.M_AttributeSetInstance_ID,
p.M_Product_Category_ID, p.Value,
po.C_BPartner_ID, po.PricePO, po.PriceLastPO, po.PriceList
FROM M_Transaction t
INNER JOIN M_Product p ON (t.M_Product_ID=p.M_Product_ID)
INNER JOIN M_Product_PO po ON (t.M_Product_ID=po.M_Product_ID)
WHERE po.IsCurrentVendor='Y';
DROP VIEW rv_m_transaction;
CREATE OR REPLACE VIEW rv_m_transaction AS
SELECT t.ad_client_id, t.ad_org_id, t.movementdate, t.movementqty, t.m_product_id, t.m_locator_id, t.m_attributesetinstance_id, p.m_product_category_id, p.value, po.c_bpartner_id, po.pricepo, po.pricelastpo, po.pricelist, t.c_projectissue_id, t.created AS m_transaction_created, t.createdby AS m_transaction_createdby, t.isactive AS m_transaction_isactive, t.m_inoutline_id, t.movementtype, t.m_productionline_id, t.m_transaction_id, t.pp_cost_collector_id, t.updated AS m_transation_updated, t.updatedby AS m_transation_updatedby, p.ad_org_id AS m_product_ad_org_id, p.classification, p.copyfrom AS m_product_copyfrom, p.created AS m_product_created, p.createdby AS m_product_createdby, p.c_revenuerecognition_id, p.c_subscriptiontype_id, p.c_taxcategory_id, p.c_uom_id AS m_product_c_uom_id, p.description AS m_product_description, p.descriptionurl, p.discontinued AS m_product_discontinued, p.discontinuedat AS m_product_discontinuedat, p.documentnote, p.group1, p.group2, p.guaranteedays, p.guaranteedaysmin, p.help, p.imageurl, p.isactive AS m_product_isactive, p.isdropship, p.isexcludeautodelivery, p.isinvoiceprintdetails, p.ispicklistprintdetails, p.ispurchased, p.isselfservice, p.issold, p.isstocked, p.issummary AS m_product_issummary, p.isverified, p.iswebstorefeatured, p.lowlevel, p.m_attributeset_id AS m_product_m_attributeset_id, p.m_attributesetinstance_id AS m_product_m_asi_id, p.m_freightcategory_id, p.m_locator_id AS m_product_m_locator_id, p.name AS m_product_name, p.processing AS m_product_processing, p.producttype, p.r_mailtext_id, p.salesrep_id AS m_product_salesrep_id, p.s_expensetype_id, p.shelfdepth, p.shelfheight, p.shelfwidth, p.sku, p.s_resource_id, p.unitsperpack, p.unitsperpallet, p.upc AS m_product_upc, p.updated AS m_product_updated, p.updatedby AS m_product_updatedby, p.versionno, p.volume, p.weight, po.ad_org_id AS m_product_po_ad_org_id, po.c_currency_id AS m_product_po_c_currency_id, po.costperorder, po.created AS m_product_po_created, po.createdby AS m_product_po_createdby, po.c_uom_id AS m_product_po_c_uom_id, po.deliverytime_actual, po.deliverytime_promised, po.discontinued AS m_product_po_discontinued, po.discontinuedat AS m_product_po_discontinuedat, po.isactive AS m_product_po_isactive, po.iscurrentvendor, po.manufacturer, po.m_product_id AS m_product_po_m_product_id, po.order_min, po.order_pack, po.priceeffective, po.pricelastinv, po.qualityrating, po.royaltyamt, po.upc AS m_product_po_upc, po.updated AS m_product_po_updated, po.updatedby AS m_product_po_updatedby, po.vendorcategory, po.vendorproductno
FROM m_transaction t
JOIN m_product p ON t.m_product_id = p.m_product_id
JOIN m_product_po po ON t.m_product_id = po.m_product_id
WHERE po.iscurrentvendor = 'Y';

View File

@ -1,55 +1,13 @@
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';
DROP VIEW rv_openitem;
CREATE OR REPLACE VIEW rv_openitem 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, NULL AS c_invoicepayschedule_id, i.invoicecollectiontype, i.c_campaign_id, i.c_project_id, i.c_activity_id, i.c_invoice_ad_orgtrx_id AS ad_orgtrx_id, i.ad_user_id, i.c_bpartner_location_id, i.c_charge_id, i.c_doctype_id, i.c_doctypetarget_id, i.c_dunninglevel_id, i.chargeamt, i.c_payment_id, i.created, i.createdby, i.dateordered, i.dateprinted, i.description, i.docaction, i.docstatus, i.dunninggrace, i.generateto, i.isactive, i.isapproved, i.isdiscountprinted, i.isindispute, i.ispaid, i.isprinted, i.c_invoice_isselfservice AS isselfservice, i.istaxincluded, i.istransferred, i.m_pricelist_id, i.m_rma_id, i.paymentrule, i.poreference, i.posted, i.processedon, i.processing, i.ref_invoice_id, i.reversal_id, i.salesrep_id, i.sendemail, i.totallines, i.updated, i.updatedby, i.user1_id, i.user2_id
FROM rv_c_invoice i
JOIN c_paymentterm p ON i.c_paymentterm_id = p.c_paymentterm_id
WHERE 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, i.c_invoice_ad_orgtrx_id AS ad_orgtrx_id, i.ad_user_id, i.c_bpartner_location_id, i.c_charge_id, i.c_doctype_id, i.c_doctypetarget_id, i.c_dunninglevel_id, i.chargeamt, i.c_payment_id, i.created, i.createdby, i.dateordered, i.dateprinted, i.description, i.docaction, i.docstatus, i.dunninggrace, i.generateto, i.isactive, i.isapproved, i.isdiscountprinted, i.isindispute, i.ispaid, i.isprinted, i.c_invoice_isselfservice AS isselfservice, i.istaxincluded, i.istransferred, i.m_pricelist_id, i.m_rma_id, i.paymentrule, i.poreference, i.posted, i.processedon, i.processing, i.ref_invoice_id, i.reversal_id, i.salesrep_id, i.sendemail, i.totallines, i.updated, i.updatedby, i.user1_id, i.user2_id
FROM rv_c_invoice i
JOIN c_invoicepayschedule ips ON i.c_invoice_id = ips.c_invoice_id
WHERE invoiceopen(i.c_invoice_id, ips.c_invoicepayschedule_id) <> 0 AND i.ispayschedulevalid = 'Y' AND i.docstatus IN ('CO', 'CL') AND ips.isvalid = 'Y';

View File

@ -1,43 +1,20 @@
CREATE OR REPLACE VIEW RV_ORDERDETAIL
(AD_CLIENT_ID, AD_ORG_ID, ISACTIVE, CREATED, CREATEDBY,
UPDATED, UPDATEDBY, C_ORDER_ID, DOCSTATUS, DOCACTION,
C_DOCTYPE_ID, ISAPPROVED, ISCREDITAPPROVED, SALESREP_ID, BILL_BPARTNER_ID,
BILL_LOCATION_ID, BILL_USER_ID, ISDROPSHIP, C_BPARTNER_ID, C_BPARTNER_LOCATION_ID,
AD_USER_ID, POREFERENCE, C_CURRENCY_ID, ISSOTRX, C_CAMPAIGN_ID,
C_PROJECT_ID, C_ACTIVITY_ID, C_PROJECTPHASE_ID, C_PROJECTTASK_ID, C_ORDERLINE_ID,
DATEORDERED, DATEPROMISED, M_PRODUCT_ID, M_WAREHOUSE_ID, M_ATTRIBUTESETINSTANCE_ID,
PRODUCTATTRIBUTE, M_ATTRIBUTESET_ID, M_LOT_ID, GUARANTEEDATE, LOT,
SERNO, C_UOM_ID, QTYENTERED, QTYORDERED, QTYRESERVED,
QTYDELIVERED, QTYINVOICED, PRICEACTUAL, PRICEENTERED, QTYTODELIVER,
QTYTOINVOICE, NETAMTTOINVOICE, QTYLOSTSALES, AMTLOSTSALES, DISCOUNT,
MARGIN, MARGINAMT)
AS
SELECT l.AD_Client_ID, l.AD_Org_ID,
l.IsActive, l.Created, l.CreatedBy, l.Updated, l.UpdatedBy,
o.C_Order_ID, o.DocStatus, o.DocAction, o.C_DocType_ID, o.IsApproved, o.IsCreditApproved,
o.SalesRep_ID,
o.Bill_BPartner_ID, o.Bill_Location_ID, o.Bill_User_ID, o.IsDropShip,
l.C_BPartner_ID, l.C_BPartner_Location_ID, o.AD_User_ID,
o.POReference, o.C_Currency_ID, o.IsSOTrx,
l.C_Campaign_ID, l.C_Project_ID, l.C_Activity_ID, l.C_ProjectPhase_ID, l.C_ProjectTask_ID,
l.C_OrderLine_ID, l.DateOrdered, l.DatePromised, l.M_Product_ID, l.M_Warehouse_ID,
l.M_AttributeSetInstance_ID, productAttribute(l.M_AttributeSetInstance_ID) AS ProductAttribute,
pasi.M_AttributeSet_ID, pasi.M_Lot_ID, pasi.GuaranteeDate, pasi.Lot, pasi.SerNo,
l.C_UOM_ID, l.QtyEntered, l.QtyOrdered, l.QtyReserved, l.QtyDelivered, l.QtyInvoiced,
l.PriceActual, l.PriceEntered,
l.QtyOrdered-l.QtyDelivered AS QtyToDeliver,
l.QtyOrdered-l.QtyInvoiced AS QtyToInvoice,
(l.QtyOrdered-l.QtyInvoiced)*l.PriceActual AS NetAmtToInvoice,
l.QtyLostSales, l.QtyLostSales*l.PriceActual AS AmtLostSales,
CASE WHEN PriceList=0 THEN 0 ELSE
ROUND((PriceList-PriceActual)/PriceList*100,2) END AS Discount,
CASE WHEN PriceLimit=0 THEN 0 ELSE
ROUND((PriceActual-PriceLimit)/PriceLimit*100,2) END AS Margin,
CASE WHEN PriceLimit=0 THEN 0 ELSE
(PriceActual-PriceLimit)*QtyDelivered END AS MarginAmt
FROM C_Order o
INNER JOIN C_OrderLine l ON (o.C_Order_ID=l.C_Order_ID)
LEFT OUTER JOIN M_AttributeSetInstance pasi ON (l.M_AttributeSetInstance_ID=pasi.M_AttributeSetInstance_ID);
DROP VIEW rv_orderdetail;
CREATE OR REPLACE VIEW rv_orderdetail AS
SELECT l.ad_client_id, l.ad_org_id, l.isactive, l.created, l.createdby, l.updated, l.updatedby, o.c_order_id, o.docstatus, o.docaction, o.c_doctype_id, o.isapproved, o.iscreditapproved, o.salesrep_id, o.bill_bpartner_id, o.bill_location_id, o.bill_user_id, o.isdropship, l.c_bpartner_id, l.c_bpartner_location_id, o.ad_user_id, o.poreference, o.c_currency_id, o.issotrx, l.c_campaign_id, l.c_project_id, l.c_activity_id, l.c_projectphase_id, l.c_projecttask_id, l.c_orderline_id, l.dateordered, l.datepromised, l.m_product_id, l.m_warehouse_id, l.m_attributesetinstance_id, productattribute(l.m_attributesetinstance_id) AS productattribute, pasi.m_attributeset_id, pasi.m_lot_id, pasi.guaranteedate, pasi.lot, pasi.serno, l.c_uom_id, l.qtyentered, l.qtyordered, l.qtyreserved, l.qtydelivered, l.qtyinvoiced, l.priceactual, l.priceentered, l.qtyordered - l.qtydelivered AS qtytodeliver, l.qtyordered - l.qtyinvoiced AS qtytoinvoice, (l.qtyordered - l.qtyinvoiced) * l.priceactual AS netamttoinvoice, l.qtylostsales, 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.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_orgtrx_id AS c_order_ad_orgtrx_id, o.amountrefunded, o.amounttendered, o.c_activity_id AS c_order_c_activity_id, o.c_bpartner_id AS c_order_c_bpartner_id, o.c_bpartner_location_id AS c_order_c_bpartner_location_i, o.c_campaign_id AS c_order_c_compaign_id, o.c_cashline_id, o.c_cashplanline_id, o.c_charge_id AS c_order_c_charge_id, o.c_conversiontype_id, o.c_doctypetarget_id, o.chargeamt, o.copyfrom, o.c_payment_id, o.c_paymentterm_id, o.c_pos_id, o.c_project_id AS c_order_c_project_id, o.created AS c_order_created, o.createdby AS c_order_createdby, o.dateacct, o.dateordered AS c_order_dateordered, o.dateprinted, o.datepromised AS c_order_datepromised, o.deliveryrule, o.deliveryviarule, o.description AS c_order_description, o.documentno, o.dropship_bpartner_id, o.dropship_location_id, o.dropship_user_id, o.freightamt AS c_order_freightamt, o.freightcostrule, o.grandtotal, o.invoicerule, o.isactive AS c_order_isactive, o.isdelivered, o.isdiscountprinted, o.isinvoiced, o.ispayschedulevalid, o.isprinted, o.isselected, o.isselfservice, o.istaxincluded, o.istransferred, o.link_order_id, o.m_freightcategory_id, o.m_pricelist_id, o.m_shipper_id AS c_order_m_shipper_id, o.m_warehouse_id AS c_order_m_warehouse_id, o.ordertype, o.pay_bpartner_id, o.pay_location_id, o.paymentrule, o.posted, o.priorityrule, o.processed AS c_order_processed, o.processedon, o.promotioncode, o.ref_order_id, o.sendemail, o.totallines, o.updated AS c_order_updated, o.updatedby AS c_order_updatedby, o.user1_id AS c_order_user1_id, o.user2_id AS c_order_user2_id, o.volume, o.weight, l.ad_orgtrx_id AS c_orderline_ad_orgtrx_id, l.c_charge_id AS c_orderline_c_charge_id, l.c_currency_id AS c_orderline_c_currency_id, l.c_tax_id, l.datedelivered, l.dateinvoiced, l.description AS c_orderline_description, l.discount AS c_orderline_discount, l.freightamt AS c_orderline_freightamt, l.isdescription, l.line, l.linenetamt, l.link_orderline_id, l.m_promotion_id, l.m_shipper_id AS c_orderline_m_shipper_id, l.pricecost, l.pricelimit, l.pricelist, l.processed AS c_orderline_processed, l.ref_orderline_id, l.rramt, l.rrstartdate, l.s_resourceassignment_id, l.user1_id AS c_orderline_user1_id, l.user2_id AS c_orderline_user2_id, pasi.ad_org_id AS m_asi_ad_org_id, pasi.created AS m_asi_created, pasi.createdby AS m_asi_createdby, pasi.description AS m_asi_description, pasi.isactive AS m_asi_isactive, pasi.updated AS m_asi_updated, pasi.updatedby AS m_asi_updatedby
FROM c_order o
JOIN c_orderline l ON o.c_order_id = l.c_order_id
LEFT JOIN m_attributesetinstance pasi ON l.m_attributesetinstance_id = pasi.m_attributesetinstance_id;

View File

@ -1,45 +1,30 @@
CREATE OR REPLACE VIEW RV_PAYMENT
(C_PAYMENT_ID, AD_CLIENT_ID, AD_ORG_ID, ISACTIVE, CREATED,
CREATEDBY, UPDATED, UPDATEDBY, DOCUMENTNO, DATETRX,
ISRECEIPT, C_DOCTYPE_ID, TRXTYPE, C_BANKACCOUNT_ID, C_BPARTNER_ID,
C_INVOICE_ID, C_BP_BANKACCOUNT_ID, C_PAYMENTBATCH_ID, TENDERTYPE, CREDITCARDTYPE,
CREDITCARDNUMBER, CREDITCARDVV, CREDITCARDEXPMM, CREDITCARDEXPYY, MICR,
ROUTINGNO, ACCOUNTNO, CHECKNO, A_NAME, A_STREET,
A_CITY, A_STATE, A_ZIP, A_IDENT_DL, A_IDENT_SSN,
A_EMAIL, VOICEAUTHCODE, ORIG_TRXID, PONUM, C_CURRENCY_ID,
C_CONVERSIONTYPE_ID, PAYAMT, DISCOUNTAMT, WRITEOFFAMT, TAXAMT,
OVERUNDERAMT, MULTIPLIERAP, ALLOCATEDAMT, AVAILABLEAMT, ISOVERUNDERPAYMENT,
ISAPPROVED, R_PNREF, R_RESULT, R_RESPMSG, R_AUTHCODE,
R_AVSADDR, R_AVSZIP, R_INFO, PROCESSING, OPROCESSING,
DOCSTATUS, DOCACTION, ISPREPAYMENT, C_CHARGE_ID, ISRECONCILED,
ISALLOCATED, ISONLINE, PROCESSED, POSTED, C_CAMPAIGN_ID,
C_PROJECT_ID, C_ACTIVITY_ID)
AS
SELECT C_Payment_ID, AD_Client_ID, AD_Org_ID, IsActive, Created, CreatedBy, Updated, UpdatedBy,
DocumentNo, DateTrx, IsReceipt, C_DocType_ID, TrxType,
C_BankAccount_ID, C_BPartner_ID, C_Invoice_ID, C_BP_BankAccount_ID, C_PaymentBatch_ID,
TenderType, CreditCardType, CreditCardNumber, CreditCardVV, CreditCardExpMM, CreditCardExpYY,
Micr, RoutingNo, AccountNo, CheckNo,
A_Name, A_Street, A_City, A_State, A_Zip, A_Ident_DL, A_Ident_SSN, A_EMail,
VoiceAuthCode, Orig_TrxID, PONum,
C_Currency_ID, C_ConversionType_ID,
CASE IsReceipt WHEN 'Y' THEN PayAmt ELSE PayAmt*-1 END AS PayAmt,
CASE IsReceipt WHEN 'Y' THEN DiscountAmt ELSE DiscountAmt*-1 END AS DiscountAmt,
CASE IsReceipt WHEN 'Y' THEN WriteOffAmt ELSE WriteOffAmt*-1 END AS WriteOffAmt,
CASE IsReceipt WHEN 'Y' THEN TaxAmt ELSE TaxAmt*-1 END AS TaxAmt,
CASE IsReceipt WHEN 'Y' THEN OverUnderAmt ELSE OverUnderAmt*-1 END AS OverUnderAmt,
CASE IsReceipt WHEN 'Y' THEN 1 ELSE -1 END AS MultiplierAP,
paymentAllocated(C_Payment_ID, C_Currency_ID) AS AllocatedAmt,
paymentAvailable(C_Payment_ID) AS AvailableAmt,
IsOverUnderPayment, IsApproved,
R_PnRef, R_Result, R_RespMsg, R_AuthCode, R_AvsAddr, R_AvsZip, R_Info,
Processing, OProcessing, DocStatus, DocAction,
IsPrepayment, C_Charge_ID,
IsReconciled, IsAllocated, IsOnline, Processed, Posted,
C_Campaign_ID, C_Project_ID, C_Activity_ID
FROM C_Payment;
--COMMENT ON TABLE RV_PAYMENT IS 'Payment Information corrected for AP/AR';
DROP VIEW rv_payment;
CREATE OR REPLACE VIEW rv_payment AS
SELECT c_payment.c_payment_id, c_payment.ad_client_id, c_payment.ad_org_id, c_payment.isactive, c_payment.created, c_payment.createdby, c_payment.updated, c_payment.updatedby, c_payment.documentno, c_payment.datetrx, c_payment.isreceipt, c_payment.c_doctype_id, c_payment.trxtype, c_payment.c_bankaccount_id, c_payment.c_bpartner_id, c_payment.c_invoice_id, c_payment.c_bp_bankaccount_id, c_payment.c_paymentbatch_id, c_payment.tendertype, c_payment.creditcardtype, c_payment.creditcardnumber, c_payment.creditcardvv, c_payment.creditcardexpmm, c_payment.creditcardexpyy, c_payment.micr, c_payment.routingno, c_payment.accountno, c_payment.checkno, c_payment.a_name, c_payment.a_street, c_payment.a_city, c_payment.a_state, c_payment.a_zip, c_payment.a_ident_dl, c_payment.a_ident_ssn, c_payment.a_email, c_payment.voiceauthcode, c_payment.orig_trxid, c_payment.ponum, c_payment.c_currency_id, c_payment.c_conversiontype_id,
CASE c_payment.isreceipt
WHEN 'Y' THEN c_payment.payamt
ELSE c_payment.payamt * (-1)
END AS payamt,
CASE c_payment.isreceipt
WHEN 'Y' THEN c_payment.discountamt
ELSE c_payment.discountamt * (-1)
END AS discountamt,
CASE c_payment.isreceipt
WHEN 'Y' THEN c_payment.writeoffamt
ELSE c_payment.writeoffamt * (-1)
END AS writeoffamt,
CASE c_payment.isreceipt
WHEN 'Y' THEN c_payment.taxamt
ELSE c_payment.taxamt * (-1)
END AS taxamt,
CASE c_payment.isreceipt
WHEN 'Y' THEN c_payment.overunderamt
ELSE c_payment.overunderamt * (-1)
END AS overunderamt,
CASE c_payment.isreceipt
WHEN 'Y' THEN 1
ELSE (-1)
END AS multiplierap, paymentallocated(c_payment.c_payment_id, c_payment.c_currency_id) AS allocatedamt, paymentavailable(c_payment.c_payment_id) AS availableamt, c_payment.isoverunderpayment, c_payment.isapproved, c_payment.r_pnref, c_payment.r_result, c_payment.r_respmsg, c_payment.r_authcode, c_payment.r_avsaddr, c_payment.r_avszip, c_payment.r_info, c_payment.processing, c_payment.oprocessing, c_payment.docstatus, c_payment.docaction, c_payment.isprepayment, c_payment.c_charge_id, c_payment.isreconciled, c_payment.isallocated, c_payment.isonline, c_payment.processed, c_payment.posted, c_payment.c_campaign_id, c_payment.c_project_id, c_payment.c_activity_id, c_payment.a_country, c_payment.ad_orgtrx_id, c_payment.chargeamt, c_payment.c_order_id, c_payment.dateacct, c_payment.description, c_payment.isdelayedcapture, c_payment.isselfservice, c_payment.processedon, c_payment.r_authcode_dc, c_payment.r_cvv2match, c_payment.ref_payment_id, c_payment.reversal_id, c_payment.r_pnref_dc, c_payment.swipe, c_payment.user1_id, c_payment.user2_id
FROM c_payment;

View File

@ -1,32 +1,11 @@
CREATE OR REPLACE VIEW RV_STORAGE
(AD_CLIENT_ID, AD_ORG_ID, M_PRODUCT_ID, VALUE, NAME,
DESCRIPTION, UPC, SKU, C_UOM_ID, M_PRODUCT_CATEGORY_ID,
CLASSIFICATION, WEIGHT, VOLUME, VERSIONNO, GUARANTEEDAYS,
GUARANTEEDAYSMIN, M_LOCATOR_ID, M_WAREHOUSE_ID, X, Y,
Z, QTYONHAND, QTYRESERVED, QTYAVAILABLE, QTYORDERED,
DATELASTINVENTORY, M_ATTRIBUTESETINSTANCE_ID, M_ATTRIBUTESET_ID, SERNO, LOT,
M_LOT_ID, GUARANTEEDATE, SHELFLIFEDAYS, GOODFORDAYS, SHELFLIFEREMAININGPCT)
AS
SELECT s.AD_Client_ID, s.AD_Org_ID,
-- Product
s.M_Product_ID,p.Value,p.Name,p.Description,p.UPC,p.SKU,
p.C_UOM_ID,p.M_Product_Category_ID,p.Classification, p.Weight,p.Volume,p.VersionNo,
p.GuaranteeDays,p.GuaranteeDaysMin,
-- Locator
s.M_Locator_ID, l.M_Warehouse_ID, l.X, l.Y, l.Z,
-- Storage
s.QtyOnHand, s.QtyReserved, s.QtyOnHand-s.QtyReserved AS QtyAvailable,
s.QtyOrdered, s.DateLastInventory,
-- Instance
s.M_AttributeSetInstance_ID, asi.M_AttributeSet_ID, asi.SerNo, asi.Lot, asi.M_Lot_ID,
asi.GuaranteeDate, -- see PAttributeInstance.java
daysBetween(asi.GuaranteeDate,getdate()) AS ShelfLifeDays,
daysBetween(asi.GuaranteeDate,getdate())-p.GuaranteeDaysMin AS GoodForDays,
CASE WHEN COALESCE(p.GuaranteeDays,0)>0 THEN ROUND((daysBetween(asi.GuaranteeDate,getdate())/p.GuaranteeDays)*100,0) ELSE NULL END AS ShelfLifeRemainingPct
FROM M_Storage s
INNER JOIN M_Locator l ON (s.M_Locator_ID=l.M_Locator_ID)
INNER JOIN M_Product p ON (s.M_Product_ID=p.M_Product_ID)
LEFT OUTER JOIN M_AttributeSetInstance asi ON (s.M_AttributeSetInstance_ID=asi.M_AttributeSetInstance_ID);
CREATE OR REPLACE VIEW rv_storage AS
SELECT s.ad_client_id, s.ad_org_id, s.m_product_id, p.value, p.name, p.description, p.upc, p.sku, p.c_uom_id, p.m_product_category_id, p.classification, p.weight, p.volume, p.versionno, p.guaranteedays, p.guaranteedaysmin, s.m_locator_id, l.m_warehouse_id, l.x, l.y, l.z, s.qtyonhand, s.qtyreserved, s.qtyonhand - s.qtyreserved AS qtyavailable, s.qtyordered, s.datelastinventory, s.m_attributesetinstance_id, asi.m_attributeset_id, asi.serno, asi.lot, asi.m_lot_id, asi.guaranteedate, daysbetween(asi.guaranteedate, getdate()) AS shelflifedays, daysbetween(asi.guaranteedate, getdate()) - p.guaranteedaysmin AS goodfordays,
CASE
WHEN COALESCE(p.guaranteedays, 0) > 0 THEN round(daysbetween(asi.guaranteedate, getdate()) / p.guaranteedays * 100, 0)
ELSE NULL
END AS shelfliferemainingpct, s.isactive AS m_storage_isactive, s.updated AS m_storage_updated, s.updatedby AS m_storage_updatedby, l.ad_org_id AS m_locator_ad_org_id, l.isactive AS m_locator_isactive, l.isdefault, l.priorityno, l.value AS m_locator_value, p.ad_org_id AS m_product_ad_org_id, p.copyfrom AS m_product_copyfrom, p.created AS m_product_created, p.createdby AS m_product_createdby, p.c_revenuerecognition_id, p.c_subscriptiontype_id, p.c_taxcategory_id, p.descriptionurl, p.discontinued AS m_product_discontinued, p.discontinuedat AS m_product_discontinuedat, p.documentnote, p.group1, p.group2, p.help, p.imageurl, p.isactive AS m_product_isactive, p.isbom, p.isdropship, p.isexcludeautodelivery, p.isinvoiceprintdetails, p.ispicklistprintdetails, p.ispurchased, p.isselfservice, p.issold, p.isstocked, p.issummary AS m_product_issummary, p.isverified, p.iswebstorefeatured, p.lowlevel, p.m_attributeset_id AS m_product_m_attributeset_id, p.m_attributesetinstance_id AS m_product_m_asi_id, p.m_freightcategory_id, p.m_locator_id AS m_product_m_locator_id, p.processing AS m_product_processing, p.producttype, p.r_mailtext_id, p.salesrep_id AS m_product_salesrep_id, p.s_expensetype_id, p.shelfdepth, p.shelfheight, p.shelfwidth, p.s_resource_id, p.unitsperpack, p.unitsperpallet, p.updated AS m_product_updated, p.updatedby AS m_product_updatedby, asi.ad_org_id AS m_asi_ad_org_id, asi.created AS m_asi_created, asi.createdby AS m_asi_createdby, asi.description AS m_asi_description, asi.isactive AS m_asi_isactive, asi.updated AS m_asi_updated, asi.updatedby AS m_asi_updatedby
FROM m_storage s
JOIN m_locator l ON s.m_locator_id = l.m_locator_id
JOIN m_product p ON s.m_product_id = p.m_product_id
LEFT JOIN m_attributesetinstance asi ON s.m_attributesetinstance_id = asi.m_attributesetinstance_id;

File diff suppressed because one or more lines are too long

View File

@ -1,45 +1,8 @@
CREATE OR REPLACE VIEW T_INVOICEGL_V
(AD_CLIENT_ID, AD_ORG_ID, ISACTIVE, CREATED, CREATEDBY,
UPDATED, UPDATEDBY, C_INVOICE_ID, ISSOTRX, DOCUMENTNO,
DOCSTATUS, C_DOCTYPE_ID, C_ORDER_ID, DESCRIPTION, SALESREP_ID,
DATEINVOICED, DATEACCT, C_PAYMENTTERM_ID, C_BPARTNER_ID, C_BPARTNER_LOCATION_ID,
AD_USER_ID, ISSELFSERVICE, C_CURRENCY_ID, C_CONVERSIONTYPE_ID, GRANDTOTAL,
ISTAXINCLUDED, C_CAMPAIGN_ID, C_PROJECT_ID, C_ACTIVITY_ID, AD_ORGTRX_ID,
USER1_ID, USER2_ID, C_LOCFROM_ID, C_LOCTO_ID, C_SALESREGION_ID,
FACT_ACCT_ID, C_ACCTSCHEMA_ID, ACCOUNT_ID, C_PERIOD_ID, GL_CATEGORY_ID,
GL_BUDGET_ID, C_TAX_ID, M_LOCATOR_ID, POSTINGTYPE, AMTSOURCEDR,
AMTSOURCECR, AMTACCTDR, AMTACCTCR, C_UOM_ID, QTY,
AD_PINSTANCE_ID, APAR, OPENAMT, PERCENT, AMTREVALDR,
AMTREVALCR, DATEREVAL, C_CONVERSIONTYPEREVAL_ID, AMTSOURCEBALANCE, AMTACCTBALANCE,
C_DOCTYPEREVAL_ID, AMTREVALDRDIFF, AMTREVALCRDIFF, ISALLCURRENCIES, AMTACCTOPENDR,
AMTACCTOPENCR, AMTACCTOPENBALANCE)
AS
SELECT i.AD_Client_ID, i.AD_Org_ID, i.IsActive, i.Created,i.CreatedBy, i.Updated,i.UpdatedBy,
i.C_Invoice_ID, i.IsSOTrx, i.DocumentNo, i.DocStatus, i.C_DocType_ID, i.C_Order_ID,
i.Description, i.SalesRep_ID, i.DateInvoiced, i.DateAcct, i.C_PaymentTerm_ID,
i.C_BPartner_ID, i.C_BPartner_Location_ID, i.AD_User_ID, i.IsSelfService,
i.C_Currency_ID, i.C_ConversionType_ID, i.GrandTotal, i.IsTaxIncluded,
-- References
i.C_Campaign_ID, i.C_Project_ID, i.C_Activity_ID,
i.AD_OrgTrx_ID, i.User1_ID, i.User2_ID,
fa.C_LocFrom_ID, fa.C_LocTo_ID, fa.C_SalesRegion_ID,
-- Accounting
fa.Fact_Acct_ID, fa.C_AcctSchema_ID, fa.Account_ID, fa.C_Period_ID, fa.GL_Category_ID, fa.GL_Budget_ID,
fa.C_Tax_ID, fa.M_Locator_ID,
fa.PostingType, fa.AmtSourceDr, fa.AmtSourceCr,
fa.AmtAcctDr, fa.AmtAcctCr,
fa.C_UOM_ID, fa.Qty,
-- Gain/Loss
gl.AD_PInstance_ID, gl.APAR, gl.OpenAmt, gl.Percent,
gl.AmtRevalDr, gl.AmtRevalCr, gl.DateReval, gl.C_ConversionTypeReval_ID,
gl.AmtSourceBalance, gl.AmtAcctBalance,
gl.C_DocTypeReval_ID,
gl.AmtRevalDrDiff, gl.AmtRevalCrDiff, gl.IsAllCurrencies,
(fa.AmtAcctDr*gl.Percent/100) AS AmtAcctOpenDr, (fa.AmtAcctCr*gl.Percent/100) AS AmtAcctOpenCr,
((fa.AmtAcctDr-fa.AmtAcctCr)*gl.Percent/100) AS AmtAcctOpenBalance
FROM T_InvoiceGL gl
INNER JOIN C_Invoice i ON (gl.C_Invoice_ID=i.C_Invoice_ID)
INNER JOIN Fact_Acct fa ON (gl.Fact_Acct_ID=fa.Fact_Acct_ID);
DROP VIEW t_invoicegl_v;
CREATE OR REPLACE VIEW t_invoicegl_v AS
SELECT i.ad_client_id, i.ad_org_id, i.isactive, i.created, i.createdby, i.updated, i.updatedby, i.c_invoice_id, i.issotrx, i.documentno, i.docstatus, i.c_doctype_id, i.c_order_id, i.description, i.salesrep_id, i.dateinvoiced, i.dateacct, i.c_paymentterm_id, i.c_bpartner_id, i.c_bpartner_location_id, i.ad_user_id, i.isselfservice, i.c_currency_id, i.c_conversiontype_id, i.grandtotal, i.istaxincluded, i.c_campaign_id, i.c_project_id, i.c_activity_id, i.ad_orgtrx_id, i.user1_id, i.user2_id, fa.c_locfrom_id, fa.c_locto_id, fa.c_salesregion_id, fa.fact_acct_id, fa.c_acctschema_id, fa.account_id, fa.c_period_id, fa.gl_category_id, fa.gl_budget_id, fa.c_tax_id, fa.m_locator_id, fa.postingtype, fa.amtsourcedr, fa.amtsourcecr, fa.amtacctdr, fa.amtacctcr, fa.c_uom_id, fa.qty, gl.ad_pinstance_id, gl.apar, gl.openamt, gl.percent, gl.amtrevaldr, gl.amtrevalcr, gl.datereval, gl.c_conversiontypereval_id, gl.amtsourcebalance, gl.amtacctbalance, gl.c_doctypereval_id, gl.amtrevaldrdiff, gl.amtrevalcrdiff, gl.isallcurrencies, fa.amtacctdr * gl.percent / 100 AS amtacctopendr, fa.amtacctcr * gl.percent / 100 AS amtacctopencr, (fa.amtacctdr - fa.amtacctcr) * gl.percent / 100 AS amtacctopenbalance, gl.ad_org_id AS t_invoicegl_ad_org_id, gl.c_invoice_id AS t_invoicegl_c_invoice_id, gl.created AS t_invoicegl_created, gl.createdby AS t_invoicegl_createdby, gl.grandtotal AS t_invoicegl_grandtotal, gl.isactive AS t_invoicegl_isactive, gl.updated AS t_invoicegl_updated, gl.updatedby AS t_invoicegl_updatedby, i.c_charge_id AS c_invoice_c_charge_id, i.c_doctypetarget_id, i.c_dunninglevel_id, i.chargeamt, i.c_payment_id, i.dateordered, i.dateprinted, i.docaction, i.dunninggrace, i.generateto, i.invoicecollectiontype, i.isapproved, i.isdiscountprinted, i.isindispute, i.ispaid, i.ispayschedulevalid, i.isprinted, i.istransferred, i.m_pricelist_id, i.m_rma_id, i.paymentrule, i.poreference, i.posted, i.processedon, i.processing, i.ref_invoice_id, i.reversal_id, i.sendemail, i.totallines, fa.a_asset_id, fa.ad_org_id AS fact_acct_ad_org_id, fa.ad_orgtrx_id AS fact_acct_ad_orgtrx_id, fa.ad_table_id AS fact_acct_ad_table_id, fa.c_activity_id AS fact_acct_c_activity_id, fa.c_bpartner_id AS fact_acct_c_bpartner_id, fa.c_campaign_id AS fact_acct_c_campaign_id, fa.c_currency_id AS fact_acct_c_currency_id, fa.c_subacct_id, fa.dateacct AS fact_acct_dateacct, fa.datetrx, fa.description AS fact_acct_description, fa.isactive AS fact_acct_isactive, fa.line_id, fa.m_product_id AS fact_acct_m_product_id, fa.record_id, fa.updated AS fact_acct_updated, fa.updatedby AS fact_acct_updatedby, fa.user1_id AS fact_acct_user1_id, fa.user2_id AS fact_acct_user2_id, fa.userelement1_id, fa.userelement2_id
FROM t_invoicegl gl
JOIN c_invoice i ON gl.c_invoice_id = i.c_invoice_id
JOIN fact_acct fa ON gl.fact_acct_id = fa.fact_acct_id;

View File

@ -1,45 +1,8 @@
CREATE OR REPLACE VIEW T_INVOICEGL_VT
(AD_CLIENT_ID, AD_ORG_ID, ISACTIVE, CREATED, CREATEDBY,
UPDATED, UPDATEDBY, C_INVOICE_ID, ISSOTRX, DOCUMENTNO,
DOCSTATUS, C_DOCTYPE_ID, C_ORDER_ID, DESCRIPTION, SALESREP_ID,
DATEINVOICED, DATEACCT, C_PAYMENTTERM_ID, C_BPARTNER_ID, C_BPARTNER_LOCATION_ID,
AD_USER_ID, ISSELFSERVICE, C_CURRENCY_ID, C_CONVERSIONTYPE_ID, GRANDTOTAL,
ISTAXINCLUDED, C_CAMPAIGN_ID, C_PROJECT_ID, C_ACTIVITY_ID, AD_ORGTRX_ID,
USER1_ID, USER2_ID, C_LOCFROM_ID, C_LOCTO_ID, C_SALESREGION_ID,
FACT_ACCT_ID, C_ACCTSCHEMA_ID, ACCOUNT_ID, C_PERIOD_ID, GL_CATEGORY_ID,
GL_BUDGET_ID, C_TAX_ID, M_LOCATOR_ID, POSTINGTYPE, AMTSOURCEDR,
AMTSOURCECR, AMTACCTDR, AMTACCTCR, C_UOM_ID, QTY,
AD_PINSTANCE_ID, APAR, OPENAMT, PERCENT, AMTREVALDR,
AMTREVALCR, DATEREVAL, C_CONVERSIONTYPEREVAL_ID, AMTSOURCEBALANCE, AMTACCTBALANCE,
C_DOCTYPEREVAL_ID, AMTREVALDRDIFF, AMTREVALCRDIFF, ISALLCURRENCIES, AMTACCTOPENDR,
AMTACCTOPENCR, AMTACCTOPENBALANCE)
AS
SELECT i.AD_Client_ID, i.AD_Org_ID, i.IsActive, i.Created,i.CreatedBy, i.Updated,i.UpdatedBy,
i.C_Invoice_ID, i.IsSOTrx, i.DocumentNo, i.DocStatus, i.C_DocType_ID, i.C_Order_ID,
i.Description, i.SalesRep_ID, i.DateInvoiced, i.DateAcct, i.C_PaymentTerm_ID,
i.C_BPartner_ID, i.C_BPartner_Location_ID, i.AD_User_ID, i.IsSelfService,
i.C_Currency_ID, i.C_ConversionType_ID, i.GrandTotal, i.IsTaxIncluded,
-- References
i.C_Campaign_ID, i.C_Project_ID, i.C_Activity_ID,
i.AD_OrgTrx_ID, i.User1_ID, i.User2_ID,
fa.C_LocFrom_ID, fa.C_LocTo_ID, fa.C_SalesRegion_ID,
-- Accounting
fa.Fact_Acct_ID, fa.C_AcctSchema_ID, fa.Account_ID, fa.C_Period_ID, fa.GL_Category_ID, fa.GL_Budget_ID,
fa.C_Tax_ID, fa.M_Locator_ID,
fa.PostingType, fa.AmtSourceDr, fa.AmtSourceCr,
fa.AmtAcctDr, fa.AmtAcctCr,
fa.C_UOM_ID, fa.Qty,
-- Gain/Loss
gl.AD_PInstance_ID, gl.APAR, gl.OpenAmt, gl.Percent,
gl.AmtRevalDr, gl.AmtRevalCr, gl.DateReval, gl.C_ConversionTypeReval_ID,
gl.AmtSourceBalance, gl.AmtAcctBalance,
gl.C_DocTypeReval_ID,
gl.AmtRevalDrDiff, gl.AmtRevalCrDiff, gl.IsAllCurrencies,
(fa.AmtAcctDr*gl.Percent/100) AS AmtAcctOpenDr, (fa.AmtAcctCr*gl.Percent/100) AS AmtAcctOpenCr,
((fa.AmtAcctDr-fa.AmtAcctCr)*gl.Percent/100) AS AmtAcctOpenBalance
FROM T_InvoiceGL gl
INNER JOIN C_Invoice i ON (gl.C_Invoice_ID=i.C_Invoice_ID)
INNER JOIN Fact_Acct fa ON (gl.Fact_Acct_ID=fa.Fact_Acct_ID);
DROP VIEW t_invoicegl_vt;
CREATE OR REPLACE VIEW t_invoicegl_vt AS
SELECT i.ad_client_id, i.ad_org_id, i.isactive, i.created, i.createdby, i.updated, i.updatedby, i.c_invoice_id, i.issotrx, i.documentno, i.docstatus, i.c_doctype_id, i.c_order_id, i.description, i.salesrep_id, i.dateinvoiced, i.dateacct, i.c_paymentterm_id, i.c_bpartner_id, i.c_bpartner_location_id, i.ad_user_id, i.isselfservice, i.c_currency_id, i.c_conversiontype_id, i.grandtotal, i.istaxincluded, i.c_campaign_id, i.c_project_id, i.c_activity_id, i.ad_orgtrx_id, i.user1_id, i.user2_id, fa.c_locfrom_id, fa.c_locto_id, fa.c_salesregion_id, fa.fact_acct_id, fa.c_acctschema_id, fa.account_id, fa.c_period_id, fa.gl_category_id, fa.gl_budget_id, fa.c_tax_id, fa.m_locator_id, fa.postingtype, fa.amtsourcedr, fa.amtsourcecr, fa.amtacctdr, fa.amtacctcr, fa.c_uom_id, fa.qty, gl.ad_pinstance_id, gl.apar, gl.openamt, gl.percent, gl.amtrevaldr, gl.amtrevalcr, gl.datereval, gl.c_conversiontypereval_id, gl.amtsourcebalance, gl.amtacctbalance, gl.c_doctypereval_id, gl.amtrevaldrdiff, gl.amtrevalcrdiff, gl.isallcurrencies, fa.amtacctdr * gl.percent / 100 AS amtacctopendr, fa.amtacctcr * gl.percent / 100 AS amtacctopencr, (fa.amtacctdr - fa.amtacctcr) * gl.percent / 100 AS amtacctopenbalance, gl.ad_org_id AS t_invoicegl_ad_org_id, gl.c_invoice_id AS t_invoicegl_c_invoice_id, gl.created AS t_invoicegl_created, gl.createdby AS t_invoicegl_createdby, gl.grandtotal AS t_invoicegl_grandtotal, gl.isactive AS t_invoicegl_isactive, gl.updated AS t_invoicegl_updated, gl.updatedby AS t_invoicegl_updatedby, i.c_charge_id AS c_invoice_c_charge_id, i.c_doctypetarget_id, i.c_dunninglevel_id, i.chargeamt, i.c_payment_id, i.dateordered, i.dateprinted, i.docaction, i.dunninggrace, i.generateto, i.invoicecollectiontype, i.isapproved, i.isdiscountprinted, i.isindispute, i.ispaid, i.ispayschedulevalid, i.isprinted, i.istransferred, i.m_pricelist_id, i.m_rma_id, i.paymentrule, i.poreference, i.posted, i.processedon, i.processing, i.ref_invoice_id, i.reversal_id, i.sendemail, i.totallines, fa.a_asset_id, fa.ad_org_id AS fact_acct_ad_org_id, fa.ad_orgtrx_id AS fact_acct_ad_orgtrx_id, fa.ad_table_id AS fact_acct_ad_table_id, fa.c_activity_id AS fact_acct_c_activity_id, fa.c_bpartner_id AS fact_acct_c_bpartner_id, fa.c_campaign_id AS fact_acct_c_campaign_id, fa.c_currency_id AS fact_acct_c_currency_id, fa.c_subacct_id, fa.dateacct AS fact_acct_dateacct, fa.datetrx, fa.description AS fact_acct_description, fa.isactive AS fact_acct_isactive, fa.line_id, fa.m_product_id AS fact_acct_m_product_id, fa.record_id, fa.updated AS fact_acct_updated, fa.updatedby AS fact_acct_updatedby, fa.user1_id AS fact_acct_user1_id, fa.user2_id AS fact_acct_user2_id, fa.userelement1_id, fa.userelement2_id
FROM t_invoicegl gl
JOIN c_invoice i ON gl.c_invoice_id = i.c_invoice_id
JOIN fact_acct fa ON gl.fact_acct_id = fa.fact_acct_id;

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1,50 +1,13 @@
CREATE OR REPLACE VIEW C_DUNNING_LINE_V
(AD_CLIENT_ID, AD_ORG_ID, ISACTIVE, CREATED, CREATEDBY,
UPDATED, UPDATEDBY, AD_LANGUAGE, C_DUNNINGRUNLINE_ID, C_DUNNINGRUNENTRY_ID,
AMT, CONVERTEDAMT, DAYSDUE, TIMESDUNNED, INTERESTAMT,
FEEAMT, TOTALAMT, C_INVOICE_ID, ISSOTRX, DOCUMENTNO,
DOCSTATUS, DATETRX, C_DOCTYPE_ID, DOCUMENTTYPE, DESCRIPTION,
C_CURRENCY_ID, C_CAMPAIGN_ID, C_PROJECT_ID, C_ACTIVITY_ID, USER1_ID,
USER2_ID, DATEACCT, C_CONVERSIONTYPE_ID, AD_ORGTRX_ID, POREFERENCE,
DATEORDERED, DATEINVOICED, ISINDISPUTE, PAYMENTTERM, C_CHARGE_ID,
CHARGEAMT, TOTALLINES, GRANDTOTAL, AMTINWORDS, M_PRICELIST_ID,
ISPAID, ISALLOCATED, TENDERTYPE, DISCOUNTAMT)
AS
SELECT drl.AD_Client_ID, drl.AD_Org_ID, drl.IsActive, drl.Created, drl.CreatedBy, drl.Updated, drl.UpdatedBy,
cast('en_US' as varchar) AS AD_Language,
drl.C_DunningRunLine_ID, drl.C_DunningRunEntry_ID,
drl.Amt, drl.ConvertedAmt, drl.DaysDue, drl.TimesDunned,
drl.InterestAmt, drl.FeeAmt, drl.TotalAmt,
drl.C_Invoice_ID,
COALESCE(i.IsSOTrx,p.IsReceipt) AS IsSOTrx,
COALESCE(i.DocumentNo,p.DocumentNo) AS DocumentNo,
COALESCE(i.DocStatus,p.DocStatus) AS DocStatus,
COALESCE(i.DateInvoiced, p.DateTrx) AS DateTrx,
COALESCE(i.C_DocType_ID,p.C_DocType_ID) AS C_DocType_ID,
COALESCE(dt.PrintName,dtp.PrintName) AS DocumentType,
COALESCE(i.Description,p.Description) AS Description,
COALESCE(i.C_Currency_ID,p.C_Currency_ID) AS C_Currency_ID,
COALESCE(i.C_Campaign_ID,p.C_Campaign_ID) AS C_Campaign_ID,
COALESCE(i.C_Project_ID,p.C_Project_ID) AS C_Project_ID,
COALESCE(i.C_Activity_ID,p.C_Activity_ID) AS C_Activity_ID,
COALESCE(i.User1_ID,p.User1_ID) AS User1_ID,
COALESCE(i.User2_ID,p.User2_ID) AS User2_ID,
COALESCE(i.DateAcct,p.DateAcct) AS DateAcct,
COALESCE(i.C_ConversionType_ID,i.C_ConversionType_ID) AS C_ConversionType_ID,
COALESCE(i.AD_OrgTrx_ID,p.AD_OrgTrx_ID) AS AD_OrgTrx_ID,
i.POReference, i.DateOrdered,
i.DateInvoiced, i.IsInDispute,
pt.Name AS PaymentTerm,
i.C_Charge_ID, i.ChargeAmt,
i.TotalLines, i.GrandTotal, i.GrandTotal AS AmtInWords,
i.M_PriceList_ID, i.IsPaid,
p.IsAllocated, p.TenderType, p.DiscountAmt
FROM C_DunningRunLine drl
LEFT OUTER JOIN C_Invoice i ON (drl.C_Invoice_ID=i.C_Invoice_ID)
LEFT OUTER JOIN C_DocType dt ON (i.C_DocType_ID=dt.C_DocType_ID)
LEFT OUTER JOIN C_PaymentTerm pt ON (i.C_PaymentTerm_ID=pt.C_PaymentTerm_ID)
LEFT OUTER JOIN C_Payment p ON (drl.C_Payment_ID=p.C_Payment_ID)
LEFT OUTER JOIN C_DocType dtp ON (p.C_DocType_ID=dtp.C_DocType_ID);
DROP VIEW c_dunning_line_v;
CREATE OR REPLACE VIEW c_dunning_line_v AS
SELECT drl.ad_client_id, drl.ad_org_id, drl.isactive, drl.created, drl.createdby, drl.updated, drl.updatedby,
'en_US'::character varying AS ad_language,
drl.c_dunningrunline_id, drl.c_dunningrunentry_id, drl.amt, drl.convertedamt, drl.daysdue, drl.timesdunned, drl.interestamt, drl.feeamt, drl.totalamt, drl.c_invoice_id, COALESCE(i.issotrx, p.isreceipt) AS issotrx, COALESCE(i.documentno, p.documentno) AS documentno, COALESCE(i.docstatus, p.docstatus) AS docstatus, COALESCE(i.dateinvoiced, p.datetrx) AS datetrx, COALESCE(i.c_doctype_id, p.c_doctype_id) AS c_doctype_id, COALESCE(dt.printname, dtp.printname) AS documenttype, COALESCE(i.description, p.description) AS description, COALESCE(i.c_currency_id, p.c_currency_id) AS c_currency_id, COALESCE(i.c_campaign_id, p.c_campaign_id) AS c_campaign_id, COALESCE(i.c_project_id, p.c_project_id) AS c_project_id, COALESCE(i.c_activity_id, p.c_activity_id) AS c_activity_id, COALESCE(i.user1_id, p.user1_id) AS user1_id, COALESCE(i.user2_id, p.user2_id) AS user2_id, COALESCE(i.dateacct, p.dateacct) AS dateacct, COALESCE(i.c_conversiontype_id, p.c_conversiontype_id) AS c_conversiontype_id, COALESCE(i.ad_orgtrx_id, p.ad_orgtrx_id) AS ad_orgtrx_id, i.poreference, i.dateordered, i.dateinvoiced, i.isindispute, pt.name AS paymentterm, i.c_charge_id, i.chargeamt, i.totallines, i.grandtotal, i.grandtotal AS amtinwords, i.m_pricelist_id, i.ispaid, p.isallocated, p.tendertype, p.discountamt, drl.c_invoicepayschedule_id, drl.c_payment_id, drl.isindispute AS c_dunningrunline_isindispute, drl.openamt, drl.processed AS c_dunningrunline_processed, i.ad_org_id AS c_invoice_ad_org_id, i.ad_user_id, i.c_bpartner_id AS c_invoice_c_bpartner_id, i.c_bpartner_location_id, i.c_doctypetarget_id, i.c_dunninglevel_id, i.c_order_id AS c_invoice_c_order_id, i.c_payment_id AS c_invoice_c_payment_id, i.created AS c_invoice_created, i.createdby AS c_invoice_createdby, i.dateprinted, i.docaction, i.dunninggrace, i.generateto, i.invoicecollectiontype, i.isactive AS c_invoice_isactive, i.isapproved AS c_invoice_isapproved, i.isdiscountprinted, i.ispayschedulevalid, i.isprinted, i.isselfservice AS c_invoice_isselfservice, i.istaxincluded, i.istransferred, i.m_rma_id, i.paymentrule, i.posted AS c_invoice_posted, i.processedon AS c_invoice_processedon, i.processing, i.ref_invoice_id, i.reversal_id AS c_invoice_reversal_id, i.salesrep_id, i.sendemail, i.updated AS c_invoice_updated, i.updatedby AS c_invoice_updatedby, pt.ad_org_id AS c_paymentterm_ad_org_id, pt.afterdelivery, pt.c_paymentterm_id, pt.description AS c_paymentterm_description, pt.discount, pt.discount2, pt.discountdays, pt.discountdays2, pt.documentnote, pt.fixmonthcutoff, pt.fixmonthday, pt.fixmonthoffset, pt.gracedays, pt.isactive AS c_paymentterm_isactive, pt.isduefixed, pt.isnextbusinessday, pt.isvalid, pt.netday, pt.netdays, pt.paymenttermusage, pt.value AS c_paymentterm_value, p.a_city, p.a_country, p.ad_org_id AS c_payment_ad_org_id, p.a_email, p.a_ident_dl, p.a_name, p.a_state, p.a_street, p.a_zip, p.c_bpartner_id AS c_payment_c_bpartner_id, p.c_charge_id AS c_payment_c_charge_id, p.chargeamt AS c_payment_chargeamt, p.checkno, p.c_invoice_id AS c_payment_c_invoice_id, p.c_order_id AS c_payment_c_order_id, p.c_paymentbatch_id, p.created AS c_payment_created, p.createdby AS c_payment_createdby, p.isactive AS c_payment_isactive, p.isapproved, p.isdelayedcapture, p.isonline, p.isoverunderpayment, p.isprepayment, p.isreconciled, p.isselfservice AS c_payment_isselfservice, p.micr, p.orig_trxid, p.overunderamt, p.payamt, p.ponum, p.posted AS c_payment_posted, p.processed AS c_payment_processed, p.processedon AS c_payment_processedon, p.r_authcode, p.r_authcode_dc, p.r_avsaddr, p.r_avszip, p.r_cvv2match, p.ref_payment_id, p.reversal_id AS c_payment_reversal_id, p.r_info, p.routingno, p.r_pnref, p.r_pnref_dc, p.r_respmsg, p.r_result, p.swipe, p.taxamt, p.trxtype, p.updated AS c_payment_updated, p.updatedby AS c_payment_updatedby, p.voiceauthcode, p.writeoffamt
FROM c_dunningrunline drl
LEFT JOIN c_invoice i ON drl.c_invoice_id = i.c_invoice_id
LEFT JOIN c_doctype dt ON i.c_doctype_id = dt.c_doctype_id
LEFT JOIN c_paymentterm pt ON i.c_paymentterm_id = pt.c_paymentterm_id
LEFT JOIN c_payment p ON drl.c_payment_id = p.c_payment_id
LEFT JOIN c_doctype dtp ON p.c_doctype_id = dtp.c_doctype_id;

View File

@ -1,52 +1,13 @@
CREATE OR REPLACE VIEW C_DUNNING_LINE_VT
(AD_CLIENT_ID, AD_ORG_ID, ISACTIVE, CREATED, CREATEDBY,
UPDATED, UPDATEDBY, AD_LANGUAGE, C_DUNNINGRUNLINE_ID, C_DUNNINGRUNENTRY_ID,
AMT, CONVERTEDAMT, DAYSDUE, TIMESDUNNED, INTERESTAMT,
FEEAMT, TOTALAMT, C_INVOICE_ID, ISSOTRX, DOCUMENTNO,
DOCSTATUS, DATETRX, C_DOCTYPE_ID, DOCUMENTTYPE, DESCRIPTION,
C_CURRENCY_ID, C_CAMPAIGN_ID, C_PROJECT_ID, C_ACTIVITY_ID, USER1_ID,
USER2_ID, DATEACCT, C_CONVERSIONTYPE_ID, AD_ORGTRX_ID, POREFERENCE,
DATEORDERED, DATEINVOICED, ISINDISPUTE, PAYMENTTERM, C_CHARGE_ID,
CHARGEAMT, TOTALLINES, GRANDTOTAL, AMTINWORDS, M_PRICELIST_ID,
ISPAID, ISALLOCATED, TENDERTYPE, DISCOUNTAMT)
AS
SELECT drl.AD_Client_ID, drl.AD_Org_ID, drl.IsActive, drl.Created, drl.CreatedBy, drl.Updated, drl.UpdatedBy,
COALESCE(dt.AD_Language,dtp.AD_Language) AS AD_Language,
drl.C_DunningRunLine_ID, drl.C_DunningRunEntry_ID,
drl.Amt, drl.ConvertedAmt, drl.DaysDue, drl.TimesDunned,
drl.InterestAmt, drl.FeeAmt, drl.TotalAmt,
drl.C_Invoice_ID,
COALESCE(i.IsSOTrx,p.IsReceipt) AS IsSOTrx,
COALESCE(i.DocumentNo,p.DocumentNo) AS DocumentNo,
COALESCE(i.DocStatus,p.DocStatus) AS DocStatus,
COALESCE(i.DateInvoiced, p.DateTrx) AS DateTrx,
COALESCE(i.C_DocType_ID,p.C_DocType_ID) AS C_DocType_ID,
COALESCE(dt.PrintName,dtp.PrintName) AS DocumentType,
COALESCE(i.Description,p.Description) AS Description,
COALESCE(i.C_Currency_ID,p.C_Currency_ID) AS C_Currency_ID,
COALESCE(i.C_Campaign_ID,p.C_Campaign_ID) AS C_Campaign_ID,
COALESCE(i.C_Project_ID,p.C_Project_ID) AS C_Project_ID,
COALESCE(i.C_Activity_ID,p.C_Activity_ID) AS C_Activity_ID,
COALESCE(i.User1_ID,p.User1_ID) AS User1_ID,
COALESCE(i.User2_ID,p.User2_ID) AS User2_ID,
COALESCE(i.DateAcct,p.DateAcct) AS DateAcct,
COALESCE(i.C_ConversionType_ID,i.C_ConversionType_ID) AS C_ConversionType_ID,
COALESCE(i.AD_OrgTrx_ID,p.AD_OrgTrx_ID) AS AD_OrgTrx_ID,
i.POReference, i.DateOrdered,
i.DateInvoiced, i.IsInDispute,
pt.Name AS PaymentTerm,
i.C_Charge_ID, i.ChargeAmt,
i.TotalLines, i.GrandTotal, i.GrandTotal AS AmtInWords,
i.M_PriceList_ID, i.IsPaid,
p.IsAllocated, p.TenderType, p.DiscountAmt
FROM C_DunningRunLine drl
LEFT OUTER JOIN C_Invoice i ON (drl.C_Invoice_ID=i.C_Invoice_ID)
LEFT OUTER JOIN C_DocType_Trl dt ON (i.C_DocType_ID=dt.C_DocType_ID)
LEFT OUTER JOIN C_PaymentTerm_Trl pt ON (i.C_PaymentTerm_ID=pt.C_PaymentTerm_ID
AND pt.AD_Language=dt.AD_Language)
LEFT OUTER JOIN C_Payment p ON (drl.C_Payment_ID=p.C_Payment_ID)
LEFT OUTER JOIN C_DocType_Trl dtp ON (p.C_DocType_ID=dtp.C_DocType_ID)
WHERE COALESCE(dt.AD_Language,dtp.AD_Language)=COALESCE(dtp.AD_Language,dt.AD_Language);
DROP VIEW c_dunning_line_vt;
CREATE OR REPLACE VIEW c_dunning_line_vt AS
SELECT drl.ad_client_id, drl.ad_org_id, drl.isactive, drl.created, drl.createdby, drl.updated, drl.updatedby, COALESCE(dt.ad_language, dtp.ad_language) AS ad_language, drl.c_dunningrunline_id, drl.c_dunningrunentry_id, drl.amt, drl.convertedamt, drl.daysdue, drl.timesdunned, drl.interestamt, drl.feeamt, drl.totalamt, drl.c_invoice_id, COALESCE(i.issotrx, p.isreceipt) AS issotrx, COALESCE(i.documentno, p.documentno) AS documentno, COALESCE(i.docstatus, p.docstatus) AS docstatus, COALESCE(i.dateinvoiced, p.datetrx) AS datetrx, COALESCE(i.c_doctype_id, p.c_doctype_id) AS c_doctype_id, COALESCE(dt.printname, dtp.printname) AS documenttype, COALESCE(i.description, p.description) AS description, COALESCE(i.c_currency_id, p.c_currency_id) AS c_currency_id, COALESCE(i.c_campaign_id, p.c_campaign_id) AS c_campaign_id, COALESCE(i.c_project_id, p.c_project_id) AS c_project_id, COALESCE(i.c_activity_id, p.c_activity_id) AS c_activity_id, COALESCE(i.user1_id, p.user1_id) AS user1_id, COALESCE(i.user2_id, p.user2_id) AS user2_id, COALESCE(i.dateacct, p.dateacct) AS dateacct, COALESCE(i.c_conversiontype_id, p.c_conversiontype_id) AS c_conversiontype_id, COALESCE(i.ad_orgtrx_id, p.ad_orgtrx_id) AS ad_orgtrx_id, i.poreference, i.dateordered, i.dateinvoiced, i.isindispute, ptt.name AS paymentterm, i.c_charge_id, i.chargeamt, i.totallines, i.grandtotal, i.grandtotal AS amtinwords, i.m_pricelist_id, i.ispaid, p.isallocated, p.tendertype, p.discountamt, drl.c_invoicepayschedule_id, drl.c_payment_id, drl.isindispute AS c_dunningrunline_isindispute, drl.openamt, drl.processed AS c_dunningrunline_processed, i.ad_org_id AS c_invoice_ad_org_id, i.ad_user_id, i.c_bpartner_id AS c_invoice_c_bpartner_id, i.c_bpartner_location_id, i.c_doctypetarget_id, i.c_dunninglevel_id, i.c_order_id AS c_invoice_c_order_id, i.c_payment_id AS c_invoice_c_payment_id, i.created AS c_invoice_created, i.createdby AS c_invoice_createdby, i.dateprinted, i.docaction, i.dunninggrace, i.generateto, i.invoicecollectiontype, i.isactive AS c_invoice_isactive, i.isapproved AS c_invoice_isapproved, i.isdiscountprinted, i.ispayschedulevalid, i.isprinted, i.isselfservice AS c_invoice_isselfservice, i.istaxincluded, i.istransferred, i.m_rma_id, i.paymentrule, i.posted AS c_invoice_posted, i.processedon AS c_invoice_processedon, i.processing, i.ref_invoice_id, i.reversal_id AS c_invoice_reversal_id, i.salesrep_id, i.sendemail, i.updated AS c_invoice_updated, i.updatedby AS c_invoice_updatedby, ptt.ad_org_id AS c_paymentterm_ad_org_id, pt.afterdelivery, pt.c_paymentterm_id, ptt.description AS c_paymentterm_description, pt.discount, pt.discount2, pt.discountdays, pt.discountdays2, ptt.documentnote, pt.fixmonthcutoff, pt.fixmonthday, pt.fixmonthoffset, pt.gracedays, ptt.isactive AS c_paymentterm_isactive, pt.isduefixed, pt.isnextbusinessday, pt.isvalid, pt.netday, pt.netdays, pt.paymenttermusage, pt.value AS c_paymentterm_value, p.a_city, p.a_country, p.ad_org_id AS c_payment_ad_org_id, p.a_email, p.a_ident_dl, p.a_name, p.a_state, p.a_street, p.a_zip, p.c_bpartner_id AS c_payment_c_bpartner_id, p.c_charge_id AS c_payment_c_charge_id, p.chargeamt AS c_payment_chargeamt, p.checkno, p.c_invoice_id AS c_payment_c_invoice_id, p.c_order_id AS c_payment_c_order_id, p.c_paymentbatch_id, p.created AS c_payment_created, p.createdby AS c_payment_createdby, p.isactive AS c_payment_isactive, p.isapproved, p.isdelayedcapture, p.isonline, p.isoverunderpayment, p.isprepayment, p.isreconciled, p.isselfservice AS c_payment_isselfservice, p.micr, p.orig_trxid, p.overunderamt, p.payamt, p.ponum, p.posted AS c_payment_posted, p.processed AS c_payment_processed, p.processedon AS c_payment_processedon, p.r_authcode, p.r_authcode_dc, p.r_avsaddr, p.r_avszip, p.r_cvv2match, p.ref_payment_id, p.reversal_id AS c_payment_reversal_id, p.r_info, p.routingno, p.r_pnref, p.r_pnref_dc, p.r_respmsg, p.r_result, p.swipe, p.taxamt, p.trxtype, p.updated AS c_payment_updated, p.updatedby AS c_payment_updatedby, p.voiceauthcode, p.writeoffamt
FROM c_dunningrunline drl
LEFT JOIN c_invoice i ON drl.c_invoice_id = i.c_invoice_id
LEFT JOIN c_doctype_trl dt ON i.c_doctype_id = dt.c_doctype_id
LEFT JOIN c_paymentterm pt ON i.c_paymentterm_id = pt.c_paymentterm_id
LEFT JOIN c_paymentterm_trl ptt ON i.c_paymentterm_id = ptt.c_paymentterm_id AND ptt.ad_language = dt.ad_language
LEFT JOIN c_payment p ON drl.c_payment_id = p.c_payment_id
LEFT JOIN c_doctype_trl dtp ON p.c_doctype_id = dtp.c_doctype_id
WHERE COALESCE(dt.ad_language, dtp.ad_language) = COALESCE(dtp.ad_language, dt.ad_language);

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1,53 +1,44 @@
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.0 ELSE 1.0 END AS Multiplier,
CASE WHEN charAt(d.DocBaseType,2)='P' THEN -1.0 ELSE 1.0 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';
CREATE OR REPLACE VIEW c_invoice_v 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, NULL 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.0)
ELSE 1.0
END AS multiplier,
CASE
WHEN charat(d.docbasetype, 2) = 'P' THEN (-1.0)
ELSE 1.0
END AS multiplierap, d.docbasetype, paymenttermduedate(i.c_paymentterm_id, i.dateinvoiced) AS duedate, i.ad_orgtrx_id, i.c_payment_id, i.isselfservice, i.posted, i.processedon, i.reversal_id
FROM c_invoice i
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, i.ad_orgtrx_id, i.c_payment_id, i.isselfservice, i.posted, i.processedon, i.reversal_id
FROM c_invoice i
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' AND ips.isvalid = 'Y';

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1,42 +1,28 @@
CREATE OR REPLACE VIEW C_PAYMENT_V
(C_PAYMENT_ID, AD_CLIENT_ID, AD_ORG_ID, ISACTIVE, CREATED,
CREATEDBY, UPDATED, UPDATEDBY, DOCUMENTNO, DATETRX,
ISRECEIPT, C_DOCTYPE_ID, TRXTYPE, C_BANKACCOUNT_ID, C_BPARTNER_ID,
C_INVOICE_ID, C_BP_BANKACCOUNT_ID, C_PAYMENTBATCH_ID, TENDERTYPE, CREDITCARDTYPE,
CREDITCARDNUMBER, CREDITCARDVV, CREDITCARDEXPMM, CREDITCARDEXPYY, MICR,
ROUTINGNO, ACCOUNTNO, CHECKNO, A_NAME, A_STREET,
A_CITY, A_STATE, A_ZIP, A_IDENT_DL, A_IDENT_SSN,
A_EMAIL, VOICEAUTHCODE, ORIG_TRXID, PONUM, C_CURRENCY_ID,
C_CONVERSIONTYPE_ID, PAYAMT, DISCOUNTAMT, WRITEOFFAMT, TAXAMT,
OVERUNDERAMT, MULTIPLIERAP, ISOVERUNDERPAYMENT, ISAPPROVED, R_PNREF,
R_RESULT, R_RESPMSG, R_AUTHCODE, R_AVSADDR, R_AVSZIP,
R_INFO, PROCESSING, OPROCESSING, DOCSTATUS, DOCACTION,
ISPREPAYMENT, C_CHARGE_ID, ISRECONCILED, ISALLOCATED, ISONLINE,
PROCESSED, POSTED, C_CAMPAIGN_ID, C_PROJECT_ID, C_ACTIVITY_ID)
AS
SELECT C_Payment_ID, AD_Client_ID, AD_Org_ID, IsActive, Created, CreatedBy, Updated, UpdatedBy,
DocumentNo, DateTrx, IsReceipt, C_DocType_ID, TrxType,
C_BankAccount_ID, C_BPartner_ID, C_Invoice_ID, C_BP_BankAccount_ID, C_PaymentBatch_ID,
TenderType, CreditCardType, CreditCardNumber, CreditCardVV, CreditCardExpMM, CreditCardExpYY,
Micr, RoutingNo, AccountNo, CheckNo,
A_Name, A_Street, A_City, A_State, A_Zip, A_Ident_DL, A_Ident_SSN, A_EMail,
VoiceAuthCode, Orig_TrxID, PONum,
C_Currency_ID, C_ConversionType_ID,
CASE IsReceipt WHEN 'Y' THEN PayAmt ELSE PayAmt*-1 END AS PayAmt,
CASE IsReceipt WHEN 'Y' THEN DiscountAmt ELSE DiscountAmt*-1 END AS DiscountAmt,
CASE IsReceipt WHEN 'Y' THEN WriteOffAmt ELSE WriteOffAmt*-1 END AS WriteOffAmt,
CASE IsReceipt WHEN 'Y' THEN TaxAmt ELSE TaxAmt*-1 END AS TaxAmt,
CASE IsReceipt WHEN 'Y' THEN OverUnderAmt ELSE OverUnderAmt*-1 END AS OverUnderAmt,
CASE IsReceipt WHEN 'Y' THEN 1 ELSE -1 END AS MultiplierAP,
IsOverUnderPayment, IsApproved,
R_PnRef, R_Result, R_RespMsg, R_AuthCode, R_AvsAddr, R_AvsZip, R_Info,
Processing, OProcessing, DocStatus, DocAction,
IsPrepayment, C_Charge_ID,
IsReconciled, IsAllocated, IsOnline, Processed, Posted,
C_Campaign_ID, C_Project_ID, C_Activity_ID
FROM C_Payment;
--COMMENT ON TABLE C_PAYMENT_V IS 'Payment Information corrected for AP/AR';
CREATE OR REPLACE VIEW c_payment_v AS
SELECT c_payment.c_payment_id, c_payment.ad_client_id, c_payment.ad_org_id, c_payment.isactive, c_payment.created, c_payment.createdby, c_payment.updated, c_payment.updatedby, c_payment.documentno, c_payment.datetrx, c_payment.isreceipt, c_payment.c_doctype_id, c_payment.trxtype, c_payment.c_bankaccount_id, c_payment.c_bpartner_id, c_payment.c_invoice_id, c_payment.c_bp_bankaccount_id, c_payment.c_paymentbatch_id, c_payment.tendertype, c_payment.creditcardtype, c_payment.creditcardnumber, c_payment.creditcardvv, c_payment.creditcardexpmm, c_payment.creditcardexpyy, c_payment.micr, c_payment.routingno, c_payment.accountno, c_payment.checkno, c_payment.a_name, c_payment.a_street, c_payment.a_city, c_payment.a_state, c_payment.a_zip, c_payment.a_ident_dl, c_payment.a_ident_ssn, c_payment.a_email, c_payment.voiceauthcode, c_payment.orig_trxid, c_payment.ponum, c_payment.c_currency_id, c_payment.c_conversiontype_id,
CASE c_payment.isreceipt
WHEN 'Y' THEN c_payment.payamt
ELSE c_payment.payamt * (-1)
END AS payamt,
CASE c_payment.isreceipt
WHEN 'Y' THEN c_payment.discountamt
ELSE c_payment.discountamt * (-1)
END AS discountamt,
CASE c_payment.isreceipt
WHEN 'Y' THEN c_payment.writeoffamt
ELSE c_payment.writeoffamt * (-1)
END AS writeoffamt,
CASE c_payment.isreceipt
WHEN 'Y' THEN c_payment.taxamt
ELSE c_payment.taxamt * (-1)
END AS taxamt,
CASE c_payment.isreceipt
WHEN 'Y' THEN c_payment.overunderamt
ELSE c_payment.overunderamt * (-1)
END AS overunderamt,
CASE c_payment.isreceipt
WHEN 'Y' THEN 1
ELSE (-1)
END AS multiplierap, c_payment.isoverunderpayment, c_payment.isapproved, c_payment.r_pnref, c_payment.r_result, c_payment.r_respmsg, c_payment.r_authcode, c_payment.r_avsaddr, c_payment.r_avszip, c_payment.r_info, c_payment.processing, c_payment.oprocessing, c_payment.docstatus, c_payment.docaction, c_payment.isprepayment, c_payment.c_charge_id, c_payment.isreconciled, c_payment.isallocated, c_payment.isonline, c_payment.processed, c_payment.posted, c_payment.c_campaign_id, c_payment.c_project_id, c_payment.c_activity_id, c_payment.ad_orgtrx_id, c_payment.chargeamt, c_payment.c_order_id, c_payment.dateacct, c_payment.description, c_payment.isselfservice, c_payment.processedon, c_payment.reversal_id
FROM c_payment;

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1,17 +1,9 @@
CREATE OR REPLACE VIEW C_PAYSELECTION_REMITTANCE_V
(AD_CLIENT_ID, AD_ORG_ID, AD_LANGUAGE, C_PAYSELECTION_ID, C_PAYSELECTIONLINE_ID,
C_PAYSELECTIONCHECK_ID, PAYMENTRULE, LINE, OPENAMT, PAYAMT,
DISCOUNTAMT, DIFFERENCEAMT, C_BPARTNER_ID, DOCUMENTNO, DATEINVOICED,
GRANDTOTAL, AMTINWORDS)
AS
SELECT psl.AD_Client_ID, psl.AD_Org_ID,
cast('en_US' as varchar) AS AD_Language,
psl.C_PaySelection_ID, psl.C_PaySelectionLine_ID,
psl.C_PaySelectionCheck_ID,
psl.PaymentRule, psl.Line, psl.OpenAmt, psl.PayAmt, psl.DiscountAmt, psl.DifferenceAmt,
i.C_BPartner_ID, i.DocumentNo, i.DateInvoiced, i.GrandTotal, i.GrandTotal AS AmtInWords
FROM C_PaySelectionLine psl
INNER JOIN C_Invoice i ON (psl.C_Invoice_ID=i.C_Invoice_ID);
DROP VIEW c_payselection_remittance_v;
CREATE OR REPLACE VIEW c_payselection_remittance_v AS
SELECT psl.ad_client_id, psl.ad_org_id,
'en_US'::character varying AS ad_language,
psl.c_payselection_id, psl.c_payselectionline_id, psl.c_payselectioncheck_id, psl.paymentrule, psl.line, psl.openamt, psl.payamt, psl.discountamt, psl.differenceamt, i.c_bpartner_id, i.documentno, i.dateinvoiced, i.grandtotal, i.grandtotal AS amtinwords, psl.c_invoice_id, psl.created AS c_payselectionline_created, psl.createdby AS c_payselectionline_createdby, psl.description AS c_payselectionline_description, psl.isactive AS c_payselectionline_isactive, psl.ismanual, psl.issotrx AS c_payselectionline_issotrx, psl.processed, psl.updated AS c_payselectionline_updated, psl.updatedby AS c_payselectionline_updatedby, i.ad_org_id AS c_invoice_ad_org_id, i.ad_orgtrx_id, i.ad_user_id, i.c_activity_id, i.c_bpartner_location_id, i.c_campaign_id, i.c_charge_id, i.c_conversiontype_id, i.c_currency_id, i.c_doctype_id, i.c_doctypetarget_id, i.c_dunninglevel_id, i.chargeamt, i.c_payment_id, i.c_paymentterm_id, i.c_project_id, i.created AS c_invoice_created, i.createdby AS c_invoice_createdby, i.dateacct, i.dateordered, i.dateprinted, i.description AS c_invoice_description, i.docaction, i.docstatus, i.dunninggrace, i.generateto, i.invoicecollectiontype, i.isactive AS c_invoice_isactive, i.isapproved, i.isdiscountprinted, i.isindispute, i.ispayschedulevalid, i.isprinted, i.isselfservice AS c_invoice_isselfservice, i.issotrx AS c_invoice_issotrx, i.istaxincluded, i.istransferred, i.m_pricelist_id, i.m_rma_id, i.paymentrule AS c_invoice_paymentrule, i.poreference, i.posted, i.processedon, i.processing, i.ref_invoice_id, i.reversal_id, i.sendemail, i.totallines, i.updated AS c_invoice_updated, i.updatedby AS c_invoice_updatedby, i.user1_id, i.user2_id
FROM c_payselectionline psl
JOIN c_invoice i ON psl.c_invoice_id = i.c_invoice_id;

View File

@ -1,18 +1,8 @@
CREATE OR REPLACE VIEW C_PAYSELECTION_REMITTANCE_VT
(AD_CLIENT_ID, AD_ORG_ID, AD_LANGUAGE, C_PAYSELECTION_ID, C_PAYSELECTIONLINE_ID,
C_PAYSELECTIONCHECK_ID, PAYMENTRULE, LINE, OPENAMT, PAYAMT,
DISCOUNTAMT, DIFFERENCEAMT, C_BPARTNER_ID, DOCUMENTNO, DATEINVOICED,
GRANDTOTAL, AMTINWORDS)
AS
SELECT psl.AD_Client_ID, psl.AD_Org_ID,
l.AD_Language,
psl.C_PaySelection_ID, psl.C_PaySelectionLine_ID,
psl.C_PaySelectionCheck_ID,
psl.PaymentRule, psl.Line, psl.OpenAmt, psl.PayAmt, psl.DiscountAmt, psl.DifferenceAmt,
i.C_BPartner_ID, i.DocumentNo, i.DateInvoiced, i.GrandTotal, i.GrandTotal AS AmtInWords
FROM C_PaySelectionLine psl
INNER JOIN C_Invoice i ON (psl.C_Invoice_ID=i.C_Invoice_ID)
INNER JOIN AD_Language l ON (l.IsSystemLanguage='Y');
DROP VIEW c_payselection_remittance_vt;
CREATE OR REPLACE VIEW c_payselection_remittance_vt AS
SELECT psl.ad_client_id, psl.ad_org_id, l.ad_language, psl.c_payselection_id, psl.c_payselectionline_id, psl.c_payselectioncheck_id, psl.paymentrule, psl.line, psl.openamt, psl.payamt, psl.discountamt, psl.differenceamt, i.c_bpartner_id, i.documentno, i.dateinvoiced, i.grandtotal, i.grandtotal AS amtinwords, psl.c_invoice_id, psl.created AS c_payselectionline_created, psl.createdby AS c_payselectionline_createdby, psl.description AS c_payselectionline_description, psl.isactive AS c_payselectionline_isactive, psl.ismanual, psl.issotrx AS c_payselectionline_issotrx, psl.processed, psl.updated AS c_payselectionline_updated, psl.updatedby AS c_payselectionline_updatedby, i.ad_org_id AS c_invoice_ad_org_id, i.ad_orgtrx_id, i.ad_user_id, i.c_activity_id, i.c_bpartner_location_id, i.c_campaign_id, i.c_charge_id, i.c_conversiontype_id, i.c_currency_id, i.c_doctype_id, i.c_doctypetarget_id, i.c_dunninglevel_id, i.chargeamt, i.c_payment_id, i.c_paymentterm_id, i.c_project_id, i.created AS c_invoice_created, i.createdby AS c_invoice_createdby, i.dateacct, i.dateordered, i.dateprinted, i.description AS c_invoice_description, i.docaction, i.docstatus, i.dunninggrace, i.generateto, i.invoicecollectiontype, i.isactive AS c_invoice_isactive, i.isapproved, i.isdiscountprinted, i.isindispute, i.ispayschedulevalid, i.isprinted, i.isselfservice AS c_invoice_isselfservice, i.issotrx AS c_invoice_issotrx, i.istaxincluded, i.istransferred, i.m_pricelist_id, i.m_rma_id, i.paymentrule AS c_invoice_paymentrule, i.poreference, i.posted, i.processedon, i.processing, i.ref_invoice_id, i.reversal_id, i.sendemail, i.totallines, i.updated AS c_invoice_updated, i.updatedby AS c_invoice_updatedby, i.user1_id, i.user2_id
FROM c_payselectionline psl
JOIN c_invoice i ON psl.c_invoice_id = i.c_invoice_id
JOIN ad_language l ON l.issystemlanguage = 'Y';

View File

@ -1,28 +1,15 @@
CREATE OR REPLACE VIEW C_PROJECT_DETAILS_V
(AD_CLIENT_ID, AD_ORG_ID, ISACTIVE, CREATED, CREATEDBY,
UPDATED, UPDATEDBY, AD_LANGUAGE, C_PROJECT_ID, C_PROJECTLINE_ID,
LINE, PLANNEDQTY, PLANNEDPRICE, PLANNEDAMT, PLANNEDMARGINAMT,
COMMITTEDAMT, M_PRODUCT_ID, NAME, DESCRIPTION, DOCUMENTNOTE,
UPC, SKU, PRODUCTVALUE, M_PRODUCT_CATEGORY_ID, INVOICEDAMT,
INVOICEDQTY, COMMITTEDQTY)
AS
SELECT pl.AD_Client_ID, pl.AD_Org_ID, pl.IsActive, pl.Created, pl.CreatedBy, pl.Updated, pl.UpdatedBy,
cast('en_US' as varchar) AS AD_Language,
pj.C_Project_ID, pl.C_ProjectLine_ID,
pl.Line,
pl.PlannedQty, pl.PlannedPrice, pl.PlannedAmt, pl.PlannedMarginAmt,
pl.CommittedAmt,
pl.M_Product_ID,
COALESCE(p.Name, pl.Description) AS Name, -- main line
CASE WHEN p.Name IS NOT NULL THEN pl.Description END AS Description, -- second line
p.DocumentNote, -- third line
p.UPC, p.SKU, p.Value AS ProductValue,
pl.M_Product_Category_ID,
pl.InvoicedAmt, pl.InvoicedQty, pl.CommittedQty
FROM C_ProjectLine pl
INNER JOIN C_Project pj ON (pl.C_Project_ID=pj.C_Project_ID)
LEFT OUTER JOIN M_Product p ON (pl.M_Product_ID=p.M_Product_ID)
WHERE pl.IsPrinted='Y';
DROP VIEW c_project_details_v;
CREATE OR REPLACE VIEW c_project_details_v AS
SELECT pl.ad_client_id, pl.ad_org_id, pl.isactive, pl.created, pl.createdby, pl.updated, pl.updatedby,
'en_US'::character varying AS ad_language,
pj.c_project_id, pl.c_projectline_id, pl.line, pl.plannedqty, pl.plannedprice, pl.plannedamt, pl.plannedmarginamt, pl.committedamt, pl.m_product_id, COALESCE(p.name, pl.description) AS name,
CASE
WHEN p.name IS NOT NULL THEN pl.description
ELSE NULL
END AS description, p.documentnote, p.upc, p.sku, p.value AS productvalue, pl.m_product_category_id, pl.invoicedamt, pl.invoicedqty, pl.committedqty, pl.c_order_id, pl.c_orderpo_id, pl.c_projectissue_id, pl.c_projectphase_id, pl.c_projecttask_id, pl.dopricing, pl.isprinted, pl.processed AS c_projectline_processed, pj.ad_org_id AS c_project_ad_org_id, pj.ad_user_id, pj.c_bpartner_id, pj.c_bpartner_location_id, pj.c_bpartnersr_id, pj.c_campaign_id, pj.c_currency_id, pj.committedamt AS c_project_committedamt, pj.committedqty AS c_project_committedqty, pj.copyfrom AS c_project_copyfrom, pj.c_paymentterm_id, pj.c_phase_id, pj.c_projecttype_id, pj.created AS c_project_created, pj.createdby AS c_project_createdby, pj.datecontract, pj.datefinish, pj.description AS c_project_description, pj.generateto, pj.invoicedamt AS c_project_invoicedamt, pj.invoicedqty AS c_project_invoicedqty, pj.isactive AS c_project_isactive, pj.iscommitceiling, pj.iscommitment, pj.issummary AS c_project_issummary, pj.m_pricelist_version_id, pj.m_warehouse_id, pj.name AS c_project_name, pj.note AS c_project_note, pj.plannedamt AS c_project_plannedamt, pj.plannedmarginamt AS c_project_plannedmarginamt, pj.plannedqty AS c_project_plannedqty, pj.poreference, pj.processed AS c_project_processed, pj.processing AS c_project_processing, pj.projectbalanceamt, pj.projectcategory, pj.projectlinelevel, pj.projinvoicerule, pj.salesrep_id AS c_project_salesrep_id, pj.updated AS c_project_updated, pj.updatedby AS c_project_updatedby, pj.value AS c_project_value, p.ad_org_id AS m_product_ad_org_id, p.classification, p.copyfrom AS m_product_copyfrom, p.created AS m_product_created, p.createdby AS m_product_createdby, p.c_revenuerecognition_id, p.c_subscriptiontype_id, p.c_taxcategory_id, p.c_uom_id, p.description AS m_product_description, p.descriptionurl, p.discontinued, p.discontinuedat, p.group1, p.group2, p.guaranteedays, p.guaranteedaysmin, p.help, p.imageurl, p.isactive AS m_product_isactive, p.isdropship, p.isexcludeautodelivery, p.isinvoiceprintdetails, p.ispicklistprintdetails, p.ispurchased, p.isselfservice, p.issold, p.isstocked, p.issummary AS m_product_issummary, p.isverified, p.iswebstorefeatured, p.lowlevel, p.m_attributeset_id, p.m_attributesetinstance_id, p.m_freightcategory_id, p.m_locator_id, p.m_product_category_id AS m_product_m_prod_category_id, p.m_product_id AS m_product_m_product_id, p.processing AS m_product_processing, p.producttype, p.r_mailtext_id, p.salesrep_id AS m_product_salesrep_id, p.s_expensetype_id, p.shelfdepth, p.shelfheight, p.shelfwidth, p.s_resource_id, p.unitsperpack, p.unitsperpallet, p.updated AS m_product_updated, p.updatedby AS m_product_updatedby, p.versionno, p.volume, p.weight
FROM c_projectline pl
JOIN c_project pj ON pl.c_project_id = pj.c_project_id
LEFT JOIN m_product p ON pl.m_product_id = p.m_product_id
WHERE pl.isprinted = 'Y';

View File

@ -1,29 +1,15 @@
CREATE OR REPLACE VIEW C_PROJECT_DETAILS_VT
(AD_CLIENT_ID, AD_ORG_ID, ISACTIVE, CREATED, CREATEDBY,
UPDATED, UPDATEDBY, AD_LANGUAGE, C_PROJECT_ID, C_PROJECTLINE_ID,
LINE, PLANNEDQTY, PLANNEDPRICE, PLANNEDAMT, PLANNEDMARGINAMT,
COMMITTEDAMT, M_PRODUCT_ID, NAME, DESCRIPTION, DOCUMENTNOTE,
UPC, SKU, PRODUCTVALUE, M_PRODUCT_CATEGORY_ID, INVOICEDAMT,
INVOICEDQTY, COMMITTEDQTY)
AS
SELECT pl.AD_Client_ID, pl.AD_Org_ID, pl.IsActive, pl.Created, pl.CreatedBy, pl.Updated, pl.UpdatedBy,
l.AD_Language,
pj.C_Project_ID, pl.C_ProjectLine_ID,
pl.Line,
pl.PlannedQty, pl.PlannedPrice, pl.PlannedAmt, pl.PlannedMarginAmt,
pl.CommittedAmt,
pl.M_Product_ID,
COALESCE(p.Name, pl.Description) AS Name, -- main line
CASE WHEN p.Name IS NOT NULL THEN pl.Description END AS Description, -- second line
p.DocumentNote, -- third line
p.UPC, p.SKU, p.Value AS ProductValue,
pl.M_Product_Category_ID,
pl.InvoicedAmt, pl.InvoicedQty, pl.CommittedQty
FROM C_ProjectLine pl
INNER JOIN C_Project pj ON (pl.C_Project_ID=pj.C_Project_ID)
LEFT OUTER JOIN M_Product p ON (pl.M_Product_ID=p.M_Product_ID)
INNER JOIN AD_Language l ON (l.IsSystemLanguage='Y')
WHERE pl.IsPrinted='Y';
DROP VIEW c_project_details_vt;
CREATE OR REPLACE VIEW c_project_details_vt AS
SELECT pl.ad_client_id, pl.ad_org_id, pl.isactive, pl.created, pl.createdby, pl.updated, pl.updatedby, l.ad_language, pj.c_project_id, pl.c_projectline_id, pl.line, pl.plannedqty, pl.plannedprice, pl.plannedamt, pl.plannedmarginamt, pl.committedamt, pl.m_product_id, COALESCE(pt.name, pl.description) AS name,
CASE
WHEN pt.name IS NOT NULL THEN pl.description
ELSE NULL
END AS description, pt.documentnote, p.upc, p.sku, p.value AS productvalue, pl.m_product_category_id, pl.invoicedamt, pl.invoicedqty, pl.committedqty, pl.c_order_id, pl.c_orderpo_id, pl.c_projectissue_id, pl.c_projectphase_id, pl.c_projecttask_id, pl.dopricing, pl.isprinted, pl.processed AS c_projectline_processed, pj.ad_org_id AS c_project_ad_org_id, pj.ad_user_id, pj.c_bpartner_id, pj.c_bpartner_location_id, pj.c_bpartnersr_id, pj.c_campaign_id, pj.c_currency_id, pj.committedamt AS c_project_committedamt, pj.committedqty AS c_project_committedqty, pj.copyfrom AS c_project_copyfrom, pj.c_paymentterm_id, pj.c_phase_id, pj.c_projecttype_id, pj.created AS c_project_created, pj.createdby AS c_project_createdby, pj.datecontract, pj.datefinish, pj.description AS c_project_description, pj.generateto, pj.invoicedamt AS c_project_invoicedamt, pj.invoicedqty AS c_project_invoicedqty, pj.isactive AS c_project_isactive, pj.iscommitceiling, pj.iscommitment, pj.issummary AS c_project_issummary, pj.m_pricelist_version_id, pj.m_warehouse_id, pj.name AS c_project_name, pj.note AS c_project_note, pj.plannedamt AS c_project_plannedamt, pj.plannedmarginamt AS c_project_plannedmarginamt, pj.plannedqty AS c_project_plannedqty, pj.poreference, pj.processed AS c_project_processed, pj.processing AS c_project_processing, pj.projectbalanceamt, pj.projectcategory, pj.projectlinelevel, pj.projinvoicerule, pj.salesrep_id AS c_project_salesrep_id, pj.updated AS c_project_updated, pj.updatedby AS c_project_updatedby, pj.value AS c_project_value, pt.ad_org_id AS m_product_ad_org_id, p.classification, p.copyfrom AS m_product_copyfrom, pt.created AS m_product_created, pt.createdby AS m_product_createdby, p.c_revenuerecognition_id, p.c_subscriptiontype_id, p.c_taxcategory_id, p.c_uom_id, pt.description AS m_product_description, p.descriptionurl, p.discontinued, p.discontinuedat, p.group1, p.group2, p.guaranteedays, p.guaranteedaysmin, p.help, p.imageurl, pt.isactive AS m_product_isactive, p.isdropship, p.isexcludeautodelivery, p.isinvoiceprintdetails, p.ispicklistprintdetails, p.ispurchased, p.isselfservice, p.issold, p.isstocked, p.issummary AS m_product_issummary, p.isverified, p.iswebstorefeatured, p.lowlevel, p.m_attributeset_id, p.m_attributesetinstance_id, p.m_freightcategory_id, p.m_locator_id, p.m_product_category_id AS m_product_m_prod_category_id, p.m_product_id AS m_product_m_product_id, p.processing AS m_product_processing, p.producttype, p.r_mailtext_id, p.salesrep_id AS m_product_salesrep_id, p.s_expensetype_id, p.shelfdepth, p.shelfheight, p.shelfwidth, p.s_resource_id, p.unitsperpack, p.unitsperpallet, p.updated AS m_product_updated, p.updatedby AS m_product_updatedby, p.versionno, p.volume, p.weight
FROM c_projectline pl
JOIN c_project pj ON pl.c_project_id = pj.c_project_id
LEFT JOIN m_product p ON pl.m_product_id = p.m_product_id
LEFT JOIN m_product_trl pt ON pl.m_product_id = pt.m_product_id
JOIN ad_language l ON l.issystemlanguage = 'Y'
WHERE pl.isprinted = 'Y';

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1,75 +1,50 @@
CREATE OR REPLACE VIEW M_INOUT_LINE_V
(AD_CLIENT_ID, AD_ORG_ID, ISACTIVE, CREATED, CREATEDBY,
UPDATED, UPDATEDBY, AD_LANGUAGE, M_INOUT_ID, M_INOUTLINE_ID,
LINE, M_PRODUCT_ID, MOVEMENTQTY, QTYENTERED, UOMSYMBOL,
QTYORDERED, QTYDELIVERED, QTYBACKORDERED, NAME, DESCRIPTION,
DOCUMENTNOTE, UPC, SKU, PRODUCTVALUE, M_LOCATOR_ID,
M_WAREHOUSE_ID, X, Y, Z, M_ATTRIBUTESETINSTANCE_ID,
M_ATTRIBUTESET_ID, SERNO, LOT, M_LOT_ID, GUARANTEEDATE,
PRODUCTDESCRIPTION, IMAGEURL, C_CAMPAIGN_ID, C_PROJECT_ID, C_ACTIVITY_ID,
C_PROJECTPHASE_ID, C_PROJECTTASK_ID)
AS
SELECT iol.AD_Client_ID, iol.AD_Org_ID, iol.IsActive, iol.Created, iol.CreatedBy, iol.Updated, iol.UpdatedBy,
'en_US' AS AD_Language,
iol.M_InOut_ID, iol.M_InOutLine_ID,
iol.Line, p.M_Product_ID,
CASE WHEN iol.MovementQty<>0 OR iol.M_Product_ID IS NOT NULL THEN iol.MovementQty END AS MovementQty,
CASE WHEN iol.QtyEntered<>0 OR iol.M_Product_ID IS NOT NULL THEN iol.QtyEntered END AS QtyEntered,
CASE WHEN iol.MovementQty<>0 OR iol.M_Product_ID IS NOT NULL THEN uom.UOMSymbol END AS UOMSymbol,
ol.QtyOrdered, ol.QtyDelivered,
CASE WHEN iol.MovementQty<>0 OR iol.M_Product_ID IS NOT NULL THEN ol.QtyOrdered-ol.QtyDelivered END AS QtyBackOrdered,
COALESCE(p.Name||productAttribute(iol.M_AttributeSetInstance_ID), c.Name, iol.Description) AS Name, -- main line
CASE WHEN COALESCE(c.Name,p.Name) IS NOT NULL THEN iol.Description END AS Description, -- second line
p.DocumentNote, -- third line
p.UPC, p.SKU, p.Value AS ProductValue,
iol.M_Locator_ID, l.M_Warehouse_ID, l.X, l.Y, l.Z,
iol.M_AttributeSetInstance_ID, asi.M_AttributeSet_ID, asi.SerNo, asi.Lot, asi.M_Lot_ID,asi.GuaranteeDate,
p.Description AS ProductDescription, p.ImageURL,
iol.C_Campaign_ID, iol.C_Project_ID, iol.C_Activity_ID, iol.C_ProjectPhase_ID, iol.C_ProjectTask_ID
FROM M_InOutLine iol
INNER JOIN C_UOM uom ON (iol.C_UOM_ID=uom.C_UOM_ID)
LEFT OUTER JOIN M_Product p ON (iol.M_Product_ID=p.M_Product_ID)
LEFT OUTER JOIN M_AttributeSetInstance asi ON (iol.M_AttributeSetInstance_ID=asi.M_AttributeSetInstance_ID)
LEFT OUTER JOIN M_Locator l ON (iol.M_Locator_ID=l.M_Locator_ID)
LEFT OUTER JOIN C_OrderLine ol ON (iol.C_OrderLine_ID=ol.C_OrderLine_ID)
LEFT OUTER JOIN C_Charge c ON (iol.C_Charge_ID=c.C_Charge_ID)
UNION -- BOM lines
SELECT iol.AD_Client_ID, iol.AD_Org_ID, iol.IsActive, iol.Created, iol.CreatedBy, iol.Updated, iol.UpdatedBy,
'en_US' AS AD_Language,
iol.M_InOut_ID, iol.M_InOutLine_ID,
iol.Line+(bl.Line/100) AS Line, p.M_Product_ID,
--iol.MovementQty*b.BOMQty AS QtyInvoiced,
CASE WHEN bl.IsQtyPercentage = 'N' THEN iol.MovementQty*bl.QtyBOM ELSE iol.MovementQty*(bl.QtyBatch / 100) END AS QtyInvoiced,
--iol.QtyEntered*b.BOMQty AS QtyEntered,
CASE WHEN bl.IsQtyPercentage = 'N' THEN iol.QtyEntered*bl.QtyBOM ELSE iol.QtyEntered*(bl.QtyBatch / 100) END AS QtyEntered,
uom.UOMSymbol,
null, null, null,
p.Name, -- main line
b.Description, -- second line
p.DocumentNote, -- third line
p.UPC, p.SKU, p.Value AS ProductValue,
iol.M_Locator_ID, l.M_Warehouse_ID, l.X, l.Y, l.Z,
iol.M_AttributeSetInstance_ID, asi.M_AttributeSet_ID, asi.SerNo, asi.Lot, asi.M_Lot_ID,asi.GuaranteeDate,
p.Description AS ProductDescription, p.ImageURL,
iol.C_Campaign_ID, iol.C_Project_ID, iol.C_Activity_ID, iol.C_ProjectPhase_ID, iol.C_ProjectTask_ID
/*FROM M_Product_BOM b -- BOM lines
INNER JOIN M_InOutLine iol ON (b.M_Product_ID=iol.M_Product_ID)
INNER JOIN M_Product bp ON (bp.M_Product_ID=iol.M_Product_ID -- BOM Product
AND bp.IsBOM='Y' AND bp.IsVerified='Y' AND bp.IsPickListPrintDetails='Y')
INNER JOIN M_Product p ON (b.M_ProductBOM_ID=p.M_Product_ID) -- BOM line product
INNER JOIN C_UOM uom ON (p.C_UOM_ID=uom.C_UOM_ID)
LEFT OUTER JOIN M_AttributeSetInstance asi ON (iol.M_AttributeSetInstance_ID=asi.M_AttributeSetInstance_ID)
LEFT OUTER JOIN M_Locator l ON (iol.M_Locator_ID=l.M_Locator_ID);
*/
FROM PP_Product_BOM b -- BOM lines
INNER JOIN M_InOutLine iol ON (b.M_Product_ID=iol.M_Product_ID)
INNER JOIN M_Product bp ON (bp.M_Product_ID=iol.M_Product_ID -- BOM Product
AND bp.IsBOM='Y' AND bp.IsVerified='Y' AND bp.IsPickListPrintDetails='Y')
INNER JOIN PP_Product_BOMLine bl ON (bl.PP_Product_BOM_ID=b.PP_Product_BOM_ID)
INNER JOIN M_Product p ON (bl.M_Product_ID=p.M_Product_ID) -- BOM line product
INNER JOIN C_UOM uom ON (p.C_UOM_ID=uom.C_UOM_ID)
LEFT OUTER JOIN M_AttributeSetInstance asi ON (iol.M_AttributeSetInstance_ID=asi.M_AttributeSetInstance_ID)
LEFT OUTER JOIN M_Locator l ON (iol.M_Locator_ID=l.M_Locator_ID);
DROP VIEW m_inout_line_v;
CREATE OR REPLACE VIEW m_inout_line_v AS
SELECT iol.ad_client_id, iol.ad_org_id, iol.isactive, iol.created, iol.createdby, iol.updated, iol.updatedby, 'en_US' AS ad_language, iol.m_inout_id, iol.m_inoutline_id, iol.line, p.m_product_id,
CASE
WHEN iol.movementqty <> 0 OR iol.m_product_id IS NOT NULL THEN iol.movementqty
ELSE NULL
END AS movementqty,
CASE
WHEN iol.qtyentered <> 0 OR iol.m_product_id IS NOT NULL THEN iol.qtyentered
ELSE NULL
END AS qtyentered,
CASE
WHEN iol.movementqty <> 0 OR iol.m_product_id IS NOT NULL THEN uom.uomsymbol
ELSE NULL
END AS uomsymbol, ol.qtyordered, ol.qtydelivered,
CASE
WHEN iol.movementqty <> 0 OR iol.m_product_id IS NOT NULL THEN ol.qtyordered - ol.qtydelivered
ELSE NULL
END AS qtybackordered, COALESCE(p.name || productattribute(iol.m_attributesetinstance_id), c.name, iol.description) AS name,
CASE
WHEN COALESCE(c.name, p.name) IS NOT NULL THEN iol.description
ELSE NULL
END AS description, p.documentnote, p.upc, p.sku, p.value AS productvalue, iol.m_locator_id, l.m_warehouse_id, l.x, l.y, l.z, iol.m_attributesetinstance_id, asi.m_attributeset_id, asi.serno, asi.lot, asi.m_lot_id, asi.guaranteedate, p.description AS productdescription, p.imageurl, iol.c_campaign_id, iol.c_project_id, iol.c_activity_id, iol.c_projectphase_id, iol.c_projecttask_id, iol.ad_orgtrx_id, iol.c_charge_id, iol.confirmedqty, iol.c_orderline_id, iol.c_uom_id AS m_inoutline_c_uom_id, iol.isdescription AS m_inoutline_isdescription, iol.isinvoiced, iol.m_rmaline_id, iol.pickedqty, iol.processed AS m_inoutline_processed, iol.ref_inoutline_id, iol.reversalline_id, iol.scrappedqty, iol.targetqty, iol.user1_id AS m_inoutline_user1_id, iol.user2_id AS m_inoutline_user2_id, p.ad_org_id AS m_product_ad_org_id, p.classification, p.copyfrom AS m_product_copyfrom, p.created AS m_product_created, p.createdby AS m_product_createdby, p.c_revenuerecognition_id, p.c_subscriptiontype_id, p.c_taxcategory_id AS m_product_c_taxcategory_id, p.c_uom_id AS m_product_c_uom_id, p.descriptionurl, p.discontinued, p.discontinuedat, p.group1, p.group2, p.guaranteedays, p.guaranteedaysmin, p.help, p.isactive AS m_product_isactive, p.isbom, p.isdropship, p.isexcludeautodelivery, p.isinvoiceprintdetails, p.ispicklistprintdetails, p.ispurchased, p.isselfservice AS m_product_isselfservice, p.issold, p.isstocked, p.issummary AS m_product_issummary, p.isverified, p.iswebstorefeatured, p.lowlevel, p.m_attributeset_id AS m_product_m_attributeset_id, p.m_attributesetinstance_id AS m_product_m_asi_id, p.m_freightcategory_id, p.m_locator_id AS m_product_m_locator_id, p.m_product_category_id AS m_product_m_prod_category_id, p.processing AS m_product_processing, p.producttype, p.r_mailtext_id, p.salesrep_id AS m_product_salesrep_id, p.s_expensetype_id, p.shelfdepth, p.shelfheight, p.shelfwidth, p.s_resource_id AS m_product_s_resource_id, p.unitsperpack, p.unitsperpallet, p.updated AS m_product_updated, p.updatedby AS m_product_updatedby, p.versionno, p.volume, p.weight, uom.ad_org_id AS c_uom_ad_org_id, uom.costingprecision, uom.description AS c_uom_description, uom.isactive AS c_uom_isactive, uom.isdefault AS c_uom_isdefault, uom.name AS c_uom_name, uom.stdprecision, uom.uomtype, uom.x12de355, asi.ad_org_id AS m_asi_ad_org_id, asi.created AS m_asi_created, asi.createdby AS m_asi_createdby, asi.description AS m_asi_description, asi.isactive AS m_asi_isactive, asi.updated AS m_asi_updated, asi.updatedby AS m_asi_updatedby, l.ad_org_id AS m_locator_ad_org_id, l.isactive AS m_locator_isactive, l.isdefault, l.priorityno, l.value AS m_locator_value, ol.ad_org_id AS c_orderline_ad_org_id, ol.ad_orgtrx_id AS c_orderline_ad_orgtrx_id, ol.c_activity_id AS c_orderline_c_activity_id, ol.c_bpartner_id AS c_orderline_c_bpartner_id, ol.c_bpartner_location_id AS c_orderline_c_bp_location_id, ol.c_charge_id AS c_orderline_c_charge_id, ol.c_currency_id AS c_orderline_c_currency_id, ol.c_order_id, ol.c_project_id AS c_orderline_c_project_id, ol.c_projectphase_id AS c_orderline_c_projectphase_id, ol.c_projecttask_id AS c_orderline_c_projecttask_id, ol.created AS c_orderline_created, ol.createdby AS c_orderline_createdby, ol.c_tax_id AS c_orderline_c_tax_id, ol.c_uom_id AS c_orderline_c_uom_id, ol.datedelivered, ol.dateinvoiced, ol.dateordered, ol.datepromised AS c_orderline_datepromised, ol.description AS c_orderline_description, ol.discount, ol.freightamt AS c_orderline_freightamt, ol.isactive AS c_orderline_isactive, ol.isdescription AS c_orderline_isdescription, ol.line AS c_orderline_line, ol.linenetamt, ol.link_orderline_id, ol.m_attributesetinstance_id AS c_orderline_m_asi_id, ol.m_product_id AS c_orderline_m_product_id, ol.m_promotion_id, ol.m_shipper_id AS c_orderline_m_shipper_id, ol.m_warehouse_id AS c_orderline_warehouse_id, ol.priceactual, ol.pricecost, ol.priceentered, ol.pricelimit, ol.pricelist, ol.processed AS c_orderline_processed, ol.qtyentered AS c_orderline_qtyentered, ol.qtyinvoiced, ol.qtylostsales, ol.qtyreserved, ol.ref_orderline_id, ol.rramt, ol.rrstartdate, ol.s_resourceassignment_id, ol.updated AS c_orderline_updated, ol.updatedby AS c_orderline_updatedby, ol.user1_id AS c_orderline_user1_id, ol.user2_id AS c_orderline_user2_id, c.ad_org_id AS c_charge_c_org_id, c.c_bpartner_id AS c_charge_c_bpartner_id, c.c_chargetype_id, c.chargeamt AS c_charge_chargeamt, c.c_taxcategory_id AS c_charge_c_taxcategory_id, c.description AS c_charge_description, c.isactive AS c_charge_isactive, c.issamecurrency, c.issametax, c.istaxincluded AS c_charge_istaxincluded
FROM m_inoutline iol
JOIN c_uom uom ON iol.c_uom_id = uom.c_uom_id
LEFT JOIN m_product p ON iol.m_product_id = p.m_product_id
LEFT JOIN m_attributesetinstance asi ON iol.m_attributesetinstance_id = asi.m_attributesetinstance_id
LEFT JOIN m_locator l ON iol.m_locator_id = l.m_locator_id
LEFT JOIN c_orderline ol ON iol.c_orderline_id = ol.c_orderline_id
LEFT JOIN c_charge c ON iol.c_charge_id = c.c_charge_id
UNION
SELECT iol.ad_client_id, iol.ad_org_id, iol.isactive, iol.created, iol.createdby, iol.updated, iol.updatedby, 'en_US' AS ad_language, iol.m_inout_id, iol.m_inoutline_id, iol.line + bl.line / 100 AS line, p.m_product_id,
CASE
WHEN bl.isqtypercentage = 'N' THEN iol.movementqty * bl.qtybom
ELSE iol.movementqty * (bl.qtybatch / 100)
END AS movementqty,
CASE
WHEN bl.isqtypercentage = 'N' THEN iol.qtyentered * bl.qtybom
ELSE iol.qtyentered * (bl.qtybatch / 100)
END AS qtyentered, uom.uomsymbol, NULL AS qtyordered, NULL AS qtydelivered, NULL AS qtybackordered, p.name, b.description, p.documentnote, p.upc, p.sku, p.value AS productvalue, iol.m_locator_id, l.m_warehouse_id, l.x, l.y, l.z, iol.m_attributesetinstance_id, asi.m_attributeset_id, asi.serno, asi.lot, asi.m_lot_id, asi.guaranteedate, p.description AS productdescription, p.imageurl, iol.c_campaign_id, iol.c_project_id, iol.c_activity_id, iol.c_projectphase_id, iol.c_projecttask_id, iol.ad_orgtrx_id, iol.c_charge_id, iol.confirmedqty, iol.c_orderline_id, iol.c_uom_id AS m_inoutline_c_uom_id, iol.isdescription AS m_inoutline_isdescription, iol.isinvoiced, iol.m_rmaline_id, iol.pickedqty, iol.processed AS m_inoutline_processed, iol.ref_inoutline_id, iol.reversalline_id, iol.scrappedqty, iol.targetqty, iol.user1_id AS m_inoutline_user1_id, iol.user2_id AS m_inoutline_user2_id, p.ad_org_id AS m_product_ad_org_id, p.classification, p.copyfrom AS m_product_copyfrom, p.created AS m_product_created, p.createdby AS m_product_createdby, p.c_revenuerecognition_id, p.c_subscriptiontype_id, p.c_taxcategory_id AS m_product_c_taxcategory_id, p.c_uom_id AS m_product_c_uom_id, p.descriptionurl, p.discontinued, p.discontinuedat, p.group1, p.group2, p.guaranteedays, p.guaranteedaysmin, p.help, p.isactive AS m_product_isactive, p.isbom, p.isdropship, p.isexcludeautodelivery, p.isinvoiceprintdetails, p.ispicklistprintdetails, p.ispurchased, p.isselfservice AS m_product_isselfservice, p.issold, p.isstocked, p.issummary AS m_product_issummary, p.isverified, p.iswebstorefeatured, p.lowlevel, p.m_attributeset_id AS m_product_m_attributeset_id, p.m_attributesetinstance_id AS m_product_m_asi_id, p.m_freightcategory_id, p.m_locator_id AS m_product_m_locator_id, p.m_product_category_id AS m_product_m_prod_category_id, p.processing AS m_product_processing, p.producttype, p.r_mailtext_id, p.salesrep_id AS m_product_salesrep_id, p.s_expensetype_id, p.shelfdepth, p.shelfheight, p.shelfwidth, p.s_resource_id AS m_product_s_resource_id, p.unitsperpack, p.unitsperpallet, p.updated AS m_product_updated, p.updatedby AS m_product_updatedby, p.versionno, p.volume, p.weight, uom.ad_org_id AS c_uom_ad_org_id, uom.costingprecision, uom.description AS c_uom_description, uom.isactive AS c_uom_isactive, uom.isdefault AS c_uom_isdefault, uom.name AS c_uom_name, uom.stdprecision, uom.uomtype, uom.x12de355, asi.ad_org_id AS m_asi_ad_org_id, asi.created AS m_asi_created, asi.createdby AS m_asi_createdby, asi.description AS m_asi_description, asi.isactive AS m_asi_isactive, asi.updated AS m_asi_updated, asi.updatedby AS m_asi_updatedby, l.ad_org_id AS m_locator_ad_org_id, l.isactive AS m_locator_isactive, l.isdefault, l.priorityno, l.value AS m_locator_value, NULL AS c_orderline_ad_org_id, NULL AS c_orderline_ad_orgtrx_id, NULL AS c_orderline_c_activity_id, NULL AS c_orderline_c_bpartner_id, NULL AS c_orderline_c_bp_location_id, NULL AS c_orderline_c_charge_id, NULL AS c_orderline_c_currency_id, NULL AS c_order_id, NULL AS c_orderline_c_project_id, NULL AS c_orderline_c_projectphase_id, NULL AS c_orderline_c_projecttask_id, NULL AS c_orderline_created, NULL AS c_orderline_createdby, NULL AS c_orderline_c_tax_id, NULL AS c_orderline_c_uom_id, NULL AS datedelivered, NULL AS dateinvoiced, NULL AS dateordered, NULL AS c_orderline_datepromised, NULL AS c_orderline_description, NULL AS discount, NULL AS c_orderline_freightamt, NULL AS c_orderline_isactive, NULL AS c_orderline_isdescription, NULL AS c_orderline_line, NULL AS linenetamt, NULL AS link_orderline_id, NULL AS c_orderline_m_asi_id, NULL AS c_orderline_m_product_id, NULL AS m_promotion_id, NULL AS c_orderline_m_shipper_id, NULL AS c_orderline_warehouse_id, NULL AS priceactual, NULL AS pricecost, NULL AS priceentered, NULL AS pricelimit, NULL AS pricelist, NULL AS c_orderline_processed, NULL AS c_orderline_qtyentered, NULL AS qtyinvoiced, NULL AS qtylostsales, NULL AS qtyreserved, NULL AS ref_orderline_id, NULL AS rramt, NULL AS rrstartdate, NULL AS s_resourceassignment_id, NULL AS c_orderline_updated, NULL AS c_orderline_updatedby, NULL AS c_orderline_user1_id, NULL AS c_orderline_user2_id, NULL AS c_charge_c_org_id, NULL AS c_charge_c_bpartner_id, NULL AS c_chargetype_id, NULL AS c_charge_chargeamt, NULL AS c_charge_c_taxcategory_id, NULL AS c_charge_description, NULL AS c_charge_isactive, NULL AS issamecurrency, NULL AS issametax, NULL AS c_charge_istaxincluded
FROM pp_product_bom b
JOIN m_inoutline iol ON b.m_product_id = iol.m_product_id
JOIN m_product bp ON bp.m_product_id = iol.m_product_id AND bp.isbom = 'Y' AND bp.isverified = 'Y' AND bp.ispicklistprintdetails = 'Y'
JOIN pp_product_bomline bl ON bl.pp_product_bom_id = b.pp_product_bom_id
JOIN m_product p ON bl.m_product_id = p.m_product_id
JOIN c_uom uom ON p.c_uom_id = uom.c_uom_id
LEFT JOIN m_attributesetinstance asi ON iol.m_attributesetinstance_id = asi.m_attributesetinstance_id
LEFT JOIN m_locator l ON iol.m_locator_id = l.m_locator_id;

View File

@ -1,77 +1,55 @@
CREATE OR REPLACE VIEW M_INOUT_LINE_VT
(AD_CLIENT_ID, AD_ORG_ID, ISACTIVE, CREATED, CREATEDBY,
UPDATED, UPDATEDBY, AD_LANGUAGE, M_INOUT_ID, M_INOUTLINE_ID,
LINE, M_PRODUCT_ID, MOVEMENTQTY, QTYENTERED, UOMSYMBOL,
QTYORDERED, QTYDELIVERED, QTYBACKORDERED, NAME, DESCRIPTION,
DOCUMENTNOTE, UPC, SKU, PRODUCTVALUE, M_LOCATOR_ID,
M_WAREHOUSE_ID, X, Y, Z, M_ATTRIBUTESETINSTANCE_ID,
M_ATTRIBUTESET_ID, SERNO, LOT, M_LOT_ID, GUARANTEEDATE,
PRODUCTDESCRIPTION, IMAGEURL, C_CAMPAIGN_ID, C_PROJECT_ID, C_ACTIVITY_ID,
C_PROJECTPHASE_ID, C_PROJECTTASK_ID)
AS
SELECT iol.AD_Client_ID, iol.AD_Org_ID, iol.IsActive, iol.Created, iol.CreatedBy, iol.Updated, iol.UpdatedBy,
uom.AD_Language,
iol.M_InOut_ID, iol.M_InOutLine_ID,
iol.Line, p.M_Product_ID,
CASE WHEN iol.MovementQty<>0 OR iol.M_Product_ID IS NOT NULL THEN iol.MovementQty END AS MovementQty,
CASE WHEN iol.QtyEntered<>0 OR iol.M_Product_ID IS NOT NULL THEN iol.QtyEntered END AS QtyEntered,
CASE WHEN iol.MovementQty<>0 OR iol.M_Product_ID IS NOT NULL THEN uom.UOMSymbol END AS UOMSymbol,
ol.QtyOrdered, ol.QtyDelivered,
CASE WHEN iol.MovementQty<>0 OR iol.M_Product_ID IS NOT NULL THEN ol.QtyOrdered-ol.QtyDelivered END AS QtyBackOrdered,
COALESCE(COALESCE(pt.Name,p.Name)||productAttribute(iol.M_AttributeSetInstance_ID), c.Name, iol.Description) AS Name, -- main line
CASE WHEN COALESCE(pt.Name,p.Name,c.Name) IS NOT NULL THEN iol.Description END AS Description, -- second line
COALESCE(pt.DocumentNote, p.DocumentNote) AS DocumentNote, -- third line
p.UPC, p.SKU, p.Value AS ProductValue,
iol.M_Locator_ID, l.M_Warehouse_ID, l.X, l.Y, l.Z,
iol.M_AttributeSetInstance_ID, asi.M_AttributeSet_ID, asi.SerNo, asi.Lot, asi.M_Lot_ID,asi.GuaranteeDate,
pt.Description AS ProductDescription, p.ImageURL,
iol.C_Campaign_ID, iol.C_Project_ID, iol.C_Activity_ID, iol.C_ProjectPhase_ID, iol.C_ProjectTask_ID
FROM M_InOutLine iol
INNER JOIN C_UOM_Trl uom ON (iol.C_UOM_ID=uom.C_UOM_ID)
LEFT OUTER JOIN M_Product p ON (iol.M_Product_ID=p.M_Product_ID)
LEFT OUTER JOIN M_Product_Trl pt ON (iol.M_Product_ID=pt.M_Product_ID AND uom.AD_Language=pt.AD_Language)
LEFT OUTER JOIN M_AttributeSetInstance asi ON (iol.M_AttributeSetInstance_ID=asi.M_AttributeSetInstance_ID)
LEFT OUTER JOIN M_Locator l ON (iol.M_Locator_ID=l.M_Locator_ID)
LEFT OUTER JOIN C_OrderLine ol ON (iol.C_OrderLine_ID=ol.C_OrderLine_ID)
LEFT OUTER JOIN C_Charge_Trl c ON (iol.C_Charge_ID=c.C_Charge_ID)
UNION
SELECT iol.AD_Client_ID, iol.AD_Org_ID, iol.IsActive, iol.Created, iol.CreatedBy, iol.Updated, iol.UpdatedBy,
uom.AD_Language,
iol.M_InOut_ID, iol.M_InOutLine_ID,
iol.Line+(bl.Line/100) AS Line, p.M_Product_ID,
--iol.MovementQty*b.BOMQty AS QtyInvoiced,
CASE WHEN bl.IsQtyPercentage = 'N' THEN iol.MovementQty*bl.QtyBOM ELSE iol.MovementQty*(bl.QtyBatch / 100) END AS QtyInvoiced,
--iol.QtyEntered*b.BOMQty AS QtyEntered,
CASE WHEN bl.IsQtyPercentage = 'N' THEN iol.QtyEntered*bl.QtyBOM ELSE iol.QtyEntered*(bl.QtyBatch / 100) END AS QtyEntered,
uom.UOMSymbol,
null, null, null,
COALESCE (pt.Name, p.Name) AS Name, -- main line
b.Description, -- second line
COALESCE (pt.DocumentNote, p.DocumentNote) AS DocumentNote, -- third line
p.UPC, p.SKU, p.Value AS ProductValue,
iol.M_Locator_ID, l.M_Warehouse_ID, l.X, l.Y, l.Z,
iol.M_AttributeSetInstance_ID, asi.M_AttributeSet_ID, asi.SerNo, asi.Lot, asi.M_Lot_ID,asi.GuaranteeDate,
pt.Description AS ProductDescription, p.ImageURL,
iol.C_Campaign_ID, iol.C_Project_ID, iol.C_Activity_ID, iol.C_ProjectPhase_ID, iol.C_ProjectTask_ID
/*FROM M_Product_BOM b -- BOM lines
INNER JOIN M_InOutLine iol ON (b.M_Product_ID=iol.M_Product_ID)
INNER JOIN M_Product bp ON (bp.M_Product_ID=iol.M_Product_ID -- BOM Product
AND bp.IsBOM='Y' AND bp.IsVerified='Y' AND bp.IsPickListPrintDetails='Y')
INNER JOIN M_Product p ON (b.M_ProductBOM_ID=p.M_Product_ID) -- BOM line product
INNER JOIN C_UOM_Trl uom ON (p.C_UOM_ID=uom.C_UOM_ID)
INNER JOIN M_Product_Trl pt ON (iol.M_Product_ID=pt.M_Product_ID AND uom.AD_Language=pt.AD_Language)
LEFT OUTER JOIN M_AttributeSetInstance asi ON (iol.M_AttributeSetInstance_ID=asi.M_AttributeSetInstance_ID)
LEFT OUTER JOIN M_Locator l ON (iol.M_Locator_ID=l.M_Locator_ID);*/
FROM PP_Product_BOM b -- BOM lines
INNER JOIN M_InOutLine iol ON (b.M_Product_ID=iol.M_Product_ID)
INNER JOIN M_Product bp ON (bp.M_Product_ID=iol.M_Product_ID -- BOM Product
AND bp.IsBOM='Y' AND bp.IsVerified='Y' AND bp.IsPickListPrintDetails='Y')
INNER JOIN PP_Product_BOMLine bl ON (bl.PP_Product_BOM_ID=b.PP_Product_BOM_ID)
INNER JOIN M_Product p ON (bl.M_Product_ID=p.M_Product_ID) -- BOM line product
INNER JOIN C_UOM_Trl uom ON (p.C_UOM_ID=uom.C_UOM_ID)
INNER JOIN M_Product_Trl pt ON (bl.M_Product_ID=pt.M_Product_ID AND uom.AD_Language=pt.AD_Language)
LEFT OUTER JOIN M_AttributeSetInstance asi ON (iol.M_AttributeSetInstance_ID=asi.M_AttributeSetInstance_ID)
LEFT OUTER JOIN M_Locator l ON (iol.M_Locator_ID=l.M_Locator_ID);
DROP VIEW m_inout_line_vt;
CREATE OR REPLACE VIEW m_inout_line_vt AS
SELECT iol.ad_client_id, iol.ad_org_id, iol.isactive, iol.created, iol.createdby, iol.updated, iol.updatedby, uomt.ad_language, iol.m_inout_id, iol.m_inoutline_id, iol.line, pt.m_product_id,
CASE
WHEN iol.movementqty <> 0 OR iol.m_product_id IS NOT NULL THEN iol.movementqty
ELSE NULL
END AS movementqty,
CASE
WHEN iol.qtyentered <> 0 OR iol.m_product_id IS NOT NULL THEN iol.qtyentered
ELSE NULL
END AS qtyentered,
CASE
WHEN iol.movementqty <> 0 OR iol.m_product_id IS NOT NULL THEN uomt.uomsymbol
ELSE NULL
END AS uomsymbol, ol.qtyordered, ol.qtydelivered,
CASE
WHEN iol.movementqty <> 0 OR iol.m_product_id IS NOT NULL THEN ol.qtyordered - ol.qtydelivered
ELSE NULL
END AS qtybackordered, COALESCE(pt.name || productattribute(iol.m_attributesetinstance_id), ct.name, iol.description) AS name,
CASE
WHEN COALESCE(ct.name, pt.name) IS NOT NULL THEN iol.description
ELSE NULL
END AS description, pt.documentnote, p.upc, p.sku, p.value AS productvalue, iol.m_locator_id, l.m_warehouse_id, l.x, l.y, l.z, iol.m_attributesetinstance_id, asi.m_attributeset_id, asi.serno, asi.lot, asi.m_lot_id, asi.guaranteedate, pt.description AS productdescription, p.imageurl, iol.c_campaign_id, iol.c_project_id, iol.c_activity_id, iol.c_projectphase_id, iol.c_projecttask_id, iol.ad_orgtrx_id, iol.c_charge_id, iol.confirmedqty, iol.c_orderline_id, iol.c_uom_id AS m_inoutline_c_uom_id, iol.isdescription AS m_inoutline_isdescription, iol.isinvoiced, iol.m_rmaline_id, iol.pickedqty, iol.processed AS m_inoutline_processed, iol.ref_inoutline_id, iol.reversalline_id, iol.scrappedqty, iol.targetqty, iol.user1_id AS m_inoutline_user1_id, iol.user2_id AS m_inoutline_user2_id, pt.ad_org_id AS m_product_ad_org_id, p.classification, p.copyfrom AS m_product_copyfrom, pt.created AS m_product_created, pt.createdby AS m_product_createdby, p.c_revenuerecognition_id, p.c_subscriptiontype_id, p.c_taxcategory_id AS m_product_c_taxcategory_id, p.c_uom_id AS m_product_c_uom_id, p.descriptionurl, p.discontinued, p.discontinuedat, p.group1, p.group2, p.guaranteedays, p.guaranteedaysmin, p.help, pt.isactive AS m_product_isactive, p.isbom, p.isdropship, p.isexcludeautodelivery, p.isinvoiceprintdetails, p.ispicklistprintdetails, p.ispurchased, p.isselfservice AS m_product_isselfservice, p.issold, p.isstocked, p.issummary AS m_product_issummary, p.isverified, p.iswebstorefeatured, p.lowlevel, p.m_attributeset_id AS m_product_m_attributeset_id, p.m_attributesetinstance_id AS m_product_m_asi_id, p.m_freightcategory_id, p.m_locator_id AS m_product_m_locator_id, p.m_product_category_id AS m_product_m_prod_category_id, p.processing AS m_product_processing, p.producttype, p.r_mailtext_id, p.salesrep_id AS m_product_salesrep_id, p.s_expensetype_id, p.shelfdepth, p.shelfheight, p.shelfwidth, p.s_resource_id AS m_product_s_resource_id, p.unitsperpack, p.unitsperpallet, p.updated AS m_product_updated, p.updatedby AS m_product_updatedby, p.versionno, p.volume, p.weight, uomt.ad_org_id AS c_uom_ad_org_id, uom.costingprecision, uomt.description AS c_uom_description, uomt.isactive AS c_uom_isactive, uom.isdefault AS c_uom_isdefault, uomt.name AS c_uom_name, uom.stdprecision, uom.uomtype, uom.x12de355, asi.ad_org_id AS m_asi_ad_org_id, asi.created AS m_asi_created, asi.createdby AS m_asi_createdby, asi.description AS m_asi_description, asi.isactive AS m_asi_isactive, asi.updated AS m_asi_updated, asi.updatedby AS m_asi_updatedby, l.ad_org_id AS m_locator_ad_org_id, l.isactive AS m_locator_isactive, l.isdefault, l.priorityno, l.value AS m_locator_value, ol.ad_org_id AS c_orderline_ad_org_id, ol.ad_orgtrx_id AS c_orderline_ad_orgtrx_id, ol.c_activity_id AS c_orderline_c_activity_id, ol.c_bpartner_id AS c_orderline_c_bpartner_id, ol.c_bpartner_location_id AS c_orderline_c_bp_location_id, ol.c_charge_id AS c_orderline_c_charge_id, ol.c_currency_id AS c_orderline_c_currency_id, ol.c_order_id, ol.c_project_id AS c_orderline_c_project_id, ol.c_projectphase_id AS c_orderline_c_projectphase_id, ol.c_projecttask_id AS c_orderline_c_projecttask_id, ol.created AS c_orderline_created, ol.createdby AS c_orderline_createdby, ol.c_tax_id AS c_orderline_c_tax_id, ol.c_uom_id AS c_orderline_c_uom_id, ol.datedelivered, ol.dateinvoiced, ol.dateordered, ol.datepromised AS c_orderline_datepromised, ol.description AS c_orderline_description, ol.discount, ol.freightamt AS c_orderline_freightamt, ol.isactive AS c_orderline_isactive, ol.isdescription AS c_orderline_isdescription, ol.line AS c_orderline_line, ol.linenetamt, ol.link_orderline_id, ol.m_attributesetinstance_id AS c_orderline_m_asi_id, ol.m_product_id AS c_orderline_m_product_id, ol.m_promotion_id, ol.m_shipper_id AS c_orderline_m_shipper_id, ol.m_warehouse_id AS c_orderline_warehouse_id, ol.priceactual, ol.pricecost, ol.priceentered, ol.pricelimit, ol.pricelist, ol.processed AS c_orderline_processed, ol.qtyentered AS c_orderline_qtyentered, ol.qtyinvoiced, ol.qtylostsales, ol.qtyreserved, ol.ref_orderline_id, ol.rramt, ol.rrstartdate, ol.s_resourceassignment_id, ol.updated AS c_orderline_updated, ol.updatedby AS c_orderline_updatedby, ol.user1_id AS c_orderline_user1_id, ol.user2_id AS c_orderline_user2_id, ct.ad_org_id AS c_charge_c_org_id, c.c_bpartner_id AS c_charge_c_bpartner_id, c.c_chargetype_id, c.chargeamt AS c_charge_chargeamt, c.c_taxcategory_id AS c_charge_c_taxcategory_id, ct.description AS c_charge_description, ct.isactive AS c_charge_isactive, c.issamecurrency, c.issametax, c.istaxincluded AS c_charge_istaxincluded
FROM m_inoutline iol
JOIN c_uom uom ON iol.c_uom_id = uom.c_uom_id
JOIN c_uom_trl uomt ON iol.c_uom_id = uomt.c_uom_id
LEFT JOIN m_product p ON iol.m_product_id = p.m_product_id
LEFT JOIN m_product_trl pt ON iol.m_product_id = pt.m_product_id AND uomt.ad_language = pt.ad_language
LEFT JOIN m_attributesetinstance asi ON iol.m_attributesetinstance_id = asi.m_attributesetinstance_id
LEFT JOIN m_locator l ON iol.m_locator_id = l.m_locator_id
LEFT JOIN c_orderline ol ON iol.c_orderline_id = ol.c_orderline_id
LEFT JOIN c_charge c ON iol.c_charge_id = c.c_charge_id
LEFT JOIN c_charge_trl ct ON iol.c_charge_id = ct.c_charge_id
UNION
SELECT iol.ad_client_id, iol.ad_org_id, iol.isactive, iol.created, iol.createdby, iol.updated, iol.updatedby, uomt.ad_language, iol.m_inout_id, iol.m_inoutline_id, iol.line + bl.line / 100 AS line, pt.m_product_id,
CASE
WHEN bl.isqtypercentage = 'N' THEN iol.movementqty * bl.qtybom
ELSE iol.movementqty * (bl.qtybatch / 100)
END AS movementqty,
CASE
WHEN bl.isqtypercentage = 'N' THEN iol.qtyentered * bl.qtybom
ELSE iol.qtyentered * (bl.qtybatch / 100)
END AS qtyentered, uomt.uomsymbol, NULL AS qtyordered, NULL AS qtydelivered, NULL AS qtybackordered, pt.name, b.description, pt.documentnote, p.upc, p.sku, p.value AS productvalue, iol.m_locator_id, l.m_warehouse_id, l.x, l.y, l.z, iol.m_attributesetinstance_id, asi.m_attributeset_id, asi.serno, asi.lot, asi.m_lot_id, asi.guaranteedate, pt.description AS productdescription, p.imageurl, iol.c_campaign_id, iol.c_project_id, iol.c_activity_id, iol.c_projectphase_id, iol.c_projecttask_id, iol.ad_orgtrx_id, iol.c_charge_id, iol.confirmedqty, iol.c_orderline_id, iol.c_uom_id AS m_inoutline_c_uom_id, iol.isdescription AS m_inoutline_isdescription, iol.isinvoiced, iol.m_rmaline_id, iol.pickedqty, iol.processed AS m_inoutline_processed, iol.ref_inoutline_id, iol.reversalline_id, iol.scrappedqty, iol.targetqty, iol.user1_id AS m_inoutline_user1_id, iol.user2_id AS m_inoutline_user2_id, pt.ad_org_id AS m_product_ad_org_id, p.classification, p.copyfrom AS m_product_copyfrom, pt.created AS m_product_created, pt.createdby AS m_product_createdby, p.c_revenuerecognition_id, p.c_subscriptiontype_id, p.c_taxcategory_id AS m_product_c_taxcategory_id, p.c_uom_id AS m_product_c_uom_id, p.descriptionurl, p.discontinued, p.discontinuedat, p.group1, p.group2, p.guaranteedays, p.guaranteedaysmin, p.help, pt.isactive AS m_product_isactive, p.isbom, p.isdropship, p.isexcludeautodelivery, p.isinvoiceprintdetails, p.ispicklistprintdetails, p.ispurchased, p.isselfservice AS m_product_isselfservice, p.issold, p.isstocked, p.issummary AS m_product_issummary, p.isverified, p.iswebstorefeatured, p.lowlevel, p.m_attributeset_id AS m_product_m_attributeset_id, p.m_attributesetinstance_id AS m_product_m_asi_id, p.m_freightcategory_id, p.m_locator_id AS m_product_m_locator_id, p.m_product_category_id AS m_product_m_prod_category_id, p.processing AS m_product_processing, p.producttype, p.r_mailtext_id, p.salesrep_id AS m_product_salesrep_id, p.s_expensetype_id, p.shelfdepth, p.shelfheight, p.shelfwidth, p.s_resource_id AS m_product_s_resource_id, p.unitsperpack, p.unitsperpallet, pt.updated AS m_product_updated, pt.updatedby AS m_product_updatedby, p.versionno, p.volume, p.weight, uomt.ad_org_id AS c_uom_ad_org_id, uom.costingprecision, uomt.description AS c_uom_description, uomt.isactive AS c_uom_isactive, uom.isdefault AS c_uom_isdefault, uomt.name AS c_uom_name, uom.stdprecision, uom.uomtype, uom.x12de355, asi.ad_org_id AS m_asi_ad_org_id, asi.created AS m_asi_created, asi.createdby AS m_asi_createdby, asi.description AS m_asi_description, asi.isactive AS m_asi_isactive, asi.updated AS m_asi_updated, asi.updatedby AS m_asi_updatedby, l.ad_org_id AS m_locator_ad_org_id, l.isactive AS m_locator_isactive, l.isdefault, l.priorityno, l.value AS m_locator_value, NULL AS c_orderline_ad_org_id, NULL AS c_orderline_ad_orgtrx_id, NULL AS c_orderline_c_activity_id, NULL AS c_orderline_c_bpartner_id, NULL AS c_orderline_c_bp_location_id, NULL AS c_orderline_c_charge_id, NULL AS c_orderline_c_currency_id, NULL AS c_order_id, NULL AS c_orderline_c_project_id, NULL AS c_orderline_c_projectphase_id, NULL AS c_orderline_c_projecttask_id, NULL AS c_orderline_created, NULL AS c_orderline_createdby, NULL AS c_orderline_c_tax_id, NULL AS c_orderline_c_uom_id, NULL AS datedelivered, NULL AS dateinvoiced, NULL AS dateordered, NULL AS c_orderline_datepromised, NULL AS c_orderline_description, NULL AS discount, NULL AS c_orderline_freightamt, NULL AS c_orderline_isactive, NULL AS c_orderline_isdescription, NULL AS c_orderline_line, NULL AS linenetamt, NULL AS link_orderline_id, NULL AS c_orderline_m_asi_id, NULL AS c_orderline_m_product_id, NULL AS m_promotion_id, NULL AS c_orderline_m_shipper_id, NULL AS c_orderline_warehouse_id, NULL AS priceactual, NULL AS pricecost, NULL AS priceentered, NULL AS pricelimit, NULL AS pricelist, NULL AS c_orderline_processed, NULL AS c_orderline_qtyentered, NULL AS qtyinvoiced, NULL AS qtylostsales, NULL AS qtyreserved, NULL AS ref_orderline_id, NULL AS rramt, NULL AS rrstartdate, NULL AS s_resourceassignment_id, NULL AS c_orderline_updated, NULL AS c_orderline_updatedby, NULL AS c_orderline_user1_id, NULL AS c_orderline_user2_id, NULL AS c_charge_c_org_id, NULL AS c_charge_c_bpartner_id, NULL AS c_chargetype_id, NULL AS c_charge_chargeamt, NULL AS c_charge_c_taxcategory_id, NULL AS c_charge_description, NULL AS c_charge_isactive, NULL AS issamecurrency, NULL AS issametax, NULL AS c_charge_istaxincluded
FROM pp_product_bom b
JOIN m_inoutline iol ON b.m_product_id = iol.m_product_id
JOIN m_product bp ON bp.m_product_id = iol.m_product_id AND bp.isbom = 'Y' AND bp.isverified = 'Y' AND bp.ispicklistprintdetails = 'Y'
JOIN pp_product_bomline bl ON bl.pp_product_bom_id = b.pp_product_bom_id
JOIN m_product p ON bl.m_product_id = p.m_product_id
JOIN c_uom uom ON iol.c_uom_id = uom.c_uom_id
JOIN c_uom_trl uomt ON p.c_uom_id = uomt.c_uom_id
JOIN m_product_trl pt ON bl.m_product_id = pt.m_product_id AND uomt.ad_language = pt.ad_language
LEFT JOIN m_attributesetinstance asi ON iol.m_attributesetinstance_id = asi.m_attributesetinstance_id
LEFT JOIN m_locator l ON iol.m_locator_id = l.m_locator_id;

View File

@ -1,20 +1,7 @@
CREATE OR REPLACE VIEW RV_ALLOCATION
(C_ALLOCATIONHDR_ID, AD_CLIENT_ID, AD_ORG_ID, ISACTIVE, CREATED,
CREATEDBY, UPDATED, UPDATEDBY, DOCUMENTNO, DESCRIPTION,
DATETRX, DATEACCT, C_CURRENCY_ID, APPROVALAMT, ISMANUAL,
DOCSTATUS, DOCACTION, PROCESSED, C_ALLOCATIONLINE_ID, C_INVOICE_ID,
C_BPARTNER_ID, C_ORDER_ID, C_PAYMENT_ID, C_CASHLINE_ID, AMOUNT,
DISCOUNTAMT, WRITEOFFAMT, OVERUNDERAMT)
AS
SELECT h.C_AllocationHdr_ID, h.AD_Client_ID, h.AD_Org_ID,
h.IsActive, h.Created, h.CreatedBy, h.Updated, h.UpdatedBy,
h.DocumentNo, h.Description, h.DateTrx, h.DateAcct,
h.C_Currency_ID, h.ApprovalAmt, h.IsManual, h.DocStatus, h.DocAction, h.Processed,
l.C_AllocationLine_ID,
l.C_Invoice_ID, l.C_BPartner_ID, l.C_Order_ID, l.C_Payment_ID, l.C_CashLine_ID,
l.Amount, l.DiscountAmt, l.WriteOffAmt, l.OverUnderAmt
FROM C_AllocationHdr h
INNER JOIN C_AllocationLine l ON (h.C_AllocationHdr_ID=l.C_AllocationHdr_ID);
DROP VIEW rv_allocation;
CREATE OR REPLACE VIEW rv_allocation AS
SELECT h.c_allocationhdr_id, h.ad_client_id, h.ad_org_id, h.isactive, h.created, h.createdby, h.updated, h.updatedby, h.documentno, h.description, h.datetrx, h.dateacct, h.c_currency_id, h.approvalamt, h.ismanual, h.docstatus, h.docaction, h.processed, l.c_allocationline_id, l.c_invoice_id, l.c_bpartner_id, l.c_order_id, l.c_payment_id, l.c_cashline_id, l.amount, l.discountamt, l.writeoffamt, l.overunderamt, h.isapproved, h.posted, l.ad_org_id AS c_allocationline_ad_org_id, l.created AS c_allocationline_created, l.createdby AS c_allocationline_createdby, l.datetrx AS c_allocationline_datetrx, l.isactive AS c_allocationline_isactive, l.ismanual AS c_allocationline_ismanual, l.updated AS c_allocationline_updated, l.updatedby AS c_allocationline_updatedby
FROM c_allocationhdr h
JOIN c_allocationline l ON h.c_allocationhdr_id = l.c_allocationhdr_id;

View File

@ -1,59 +1,11 @@
CREATE OR REPLACE VIEW RV_BPARTNER
(AD_CLIENT_ID, AD_ORG_ID, ISACTIVE, CREATED, CREATEDBY,
UPDATED, UPDATEDBY, C_BPARTNER_ID, VALUE, NAME,
NAME2, DESCRIPTION, ISSUMMARY, C_BP_GROUP_ID, ISONETIME,
ISPROSPECT, ISVENDOR, ISCUSTOMER, ISEMPLOYEE, ISSALESREP,
REFERENCENO, DUNS, URL, AD_LANGUAGE, TAXID,
ISTAXEXEMPT, C_INVOICESCHEDULE_ID, RATING, SALESVOLUME, NUMBEREMPLOYEES,
NAICS, FIRSTSALE, ACQUSITIONCOST, POTENTIALLIFETIMEVALUE, ACTUALLIFETIMEVALUE,
SHAREOFCUSTOMER, PAYMENTRULE, SO_CREDITLIMIT, SO_CREDITUSED, SO_CREDITAVAILABLE,
C_PAYMENTTERM_ID, M_PRICELIST_ID, M_DISCOUNTSCHEMA_ID, C_DUNNING_ID, ISDISCOUNTPRINTED,
SO_DESCRIPTION, POREFERENCE, PAYMENTRULEPO, PO_PRICELIST_ID, PO_DISCOUNTSCHEMA_ID,
PO_PAYMENTTERM_ID, DOCUMENTCOPIES, C_GREETING_ID, INVOICERULE, DELIVERYRULE,
FREIGHTCOSTRULE, DELIVERYVIARULE, SALESREP_ID, SENDEMAIL, BPARTNER_PARENT_ID,
INVOICE_PRINTFORMAT_ID, SOCREDITSTATUS, SHELFLIFEMINPCT, AD_ORGBP_ID, FLATDISCOUNT,
TOTALOPENBALANCE, AD_USER_ID, CONTACTNAME, CONTACTDESCRIPTION, EMAIL,
SUPERVISOR_ID, EMAILUSER, BPCONTACTGREETING, TITLE, COMMENTS,
PHONE, PHONE2, FAX, LASTCONTACT, LASTRESULT,
BIRTHDAY, AD_ORGTRX_ID, EMAILVERIFY, LDAPUSER, EMAILVERIFYDATE,
NOTIFICATIONTYPE, C_BPARTNER_LOCATION_ID, POSTAL, CITY, ADDRESS1,
ADDRESS2, ADDRESS3, C_REGION_ID, REGIONNAME, C_COUNTRY_ID,
COUNTRYNAME)
AS
SELECT bp.AD_Client_ID, bp.AD_Org_ID,
bp.IsActive, bp.Created, bp.CreatedBy, bp.Updated, bp.UpdatedBy,
bp.C_BPartner_ID, bp.Value, bp.Name, bp.Name2, bp.Description, bp.IsSummary,
bp.C_BP_Group_ID, bp.IsOneTime, bp.IsProspect, bp.IsVendor, bp.IsCustomer, bp.IsEmployee, bp.IsSalesRep,
bp.ReferenceNo, bp.Duns, bp.URL, bp.AD_Language, bp.TaxID, bp.IsTaxExempt,
bp.C_InvoiceSchedule_ID, bp.Rating, bp.SalesVolume, bp.NumberEmployees, bp.NAICS,
bp.FirstSale, bp.AcqusitionCost, bp.PotentialLifeTimeValue, bp.ActualLifeTimeValue,
bp.ShareOfCustomer, bp.PaymentRule,
bp.SO_CreditLimit, bp.SO_CreditUsed, bp.SO_CreditUsed-bp.SO_CreditLimit AS SO_CreditAvailable,
bp.C_PaymentTerm_ID, bp.M_PriceList_ID, bp.M_DiscountSchema_ID, bp.C_Dunning_ID,
bp.IsDiscountPrinted, bp.SO_Description, bp.POReference, PaymentRulePO,
bp.PO_PriceList_ID, bp.PO_DiscountSchema_ID, bp.PO_PaymentTerm_ID,
bp.DocumentCopies, bp.C_Greeting_ID, bp.InvoiceRule, bp.DeliveryRule,
bp.FreightCostRule, bp.DeliveryViaRule, bp.SalesRep_ID,
bp.SendEMail, bp.BPartner_Parent_ID, bp.Invoice_PrintFormat_ID,
bp.SOCreditStatus, bp.ShelfLifeMinPct, bp.AD_OrgBP_ID,
bp.FlatDiscount, bp.TotalOpenBalance,
-- Contact
c.AD_User_ID, c.Name AS ContactName, c.Description AS ContactDescription,
c.EMail, c.Supervisor_ID,
c.EMailUser, c.C_Greeting_ID AS BPContactGreeting,
c.Title, c.Comments, c.Phone, c.Phone2, c.Fax,
c.LastContact, c.LastResult, c.BirthDay, c.AD_OrgTrx_ID,
c.EMailVerify, c.LDAPUser, c.EMailVerifyDate, c.NotificationType,
-- Location
l.C_BPartner_Location_ID, a.Postal, a.City, a.Address1, a.Address2, a.Address3,
a.C_Region_ID, COALESCE(r.Name,a.RegionName) AS RegionName,
a.C_Country_ID, cc.Name AS CountryName
FROM C_BPartner bp
LEFT OUTER JOIN C_BPartner_Location l ON (bp.C_BPartner_ID=l.C_BPartner_ID AND l.IsActive='Y')
LEFT OUTER JOIN AD_User c ON (bp.C_BPartner_ID=c.C_BPartner_ID AND (c.C_BPartner_Location_ID IS NULL OR c.C_BPartner_Location_ID=l.C_BPartner_Location_ID) AND c.IsActive='Y')
LEFT OUTER JOIN C_Location a ON (l.C_Location_ID=a.C_Location_ID)
LEFT OUTER JOIN C_Region r ON (a.C_Region_ID=r.C_Region_ID)
INNER JOIN C_Country cc ON (a.C_Country_ID=cc.C_Country_ID);
DROP VIEW rv_bpartner;
CREATE OR REPLACE VIEW rv_bpartner AS
SELECT bp.ad_client_id, bp.ad_org_id, bp.isactive, bp.created, bp.createdby, bp.updated, bp.updatedby, bp.c_bpartner_id, bp.value, bp.name, bp.name2, bp.description, bp.issummary, bp.c_bp_group_id, bp.isonetime, bp.isprospect, bp.isvendor, bp.iscustomer, bp.isemployee, bp.issalesrep, bp.referenceno, bp.duns, bp.url, bp.ad_language, bp.taxid, bp.istaxexempt, bp.c_invoiceschedule_id, bp.rating, bp.salesvolume, bp.numberemployees, bp.naics, bp.firstsale, bp.acqusitioncost, bp.potentiallifetimevalue, bp.actuallifetimevalue, bp.shareofcustomer, bp.paymentrule, bp.so_creditlimit, bp.so_creditused, bp.so_creditused - bp.so_creditlimit AS so_creditavailable, bp.c_paymentterm_id, bp.m_pricelist_id, bp.m_discountschema_id, bp.c_dunning_id, bp.isdiscountprinted, bp.so_description, bp.poreference, bp.paymentrulepo, bp.po_pricelist_id, bp.po_discountschema_id, bp.po_paymentterm_id, bp.documentcopies, bp.c_greeting_id, bp.invoicerule, bp.deliveryrule, bp.freightcostrule, bp.deliveryviarule, bp.salesrep_id, bp.sendemail, bp.bpartner_parent_id, bp.invoice_printformat_id, bp.socreditstatus, bp.shelflifeminpct, bp.ad_orgbp_id, bp.flatdiscount, bp.totalopenbalance, c.ad_user_id, c.name AS contactname, c.description AS contactdescription, c.email, c.supervisor_id, c.emailuser, c.c_greeting_id AS bpcontactgreeting, c.title, c.comments, c.phone, c.phone2, c.fax, c.lastcontact, c.lastresult, c.birthday, c.ad_orgtrx_id, c.emailverify, c.ldapuser, c.emailverifydate, c.notificationtype, l.c_bpartner_location_id, a.postal, a.city, a.address1, a.address2, a.address3, a.c_region_id, COALESCE(r.name, a.regionname) AS regionname, a.c_country_id, cc.name AS countryname, bp.c_taxgroup_id AS c_bp_c_taxgroup_id, bp.dunninggrace AS c_bp_dunninggrace, bp.ismanufacturer AS c_bp_ismanufacturer, bp.ispotaxexempt AS c_bp_ispotaxexempt, bp.logo_id AS c_bp_logo_id, l.ad_org_id AS c_bp_location_ad_org_id, l.c_bpartner_id AS c_bp_location_c_bpartner_id, l.c_location_id AS c_bp_location_c_location_id, l.created AS c_bp_location_created, l.createdby AS c_bp_location_createdby, l.c_salesregion_id AS c_bp_location_salesregion_id, l.fax AS c_bp_location_fax, l.isactive AS c_bp_location_isactive, l.isbillto AS c_bp_location_isbillto, l.isdn AS c_bp_location_isdn, l.ispayfrom AS c_bp_location_ispayfrom, l.isremitto AS c_bp_location_isremitto, l.isshipto AS c_bp_location_isshipto, l.name AS c_bp_location_name, l.phone AS c_bp_location_phone, l.phone2 AS c_bp_location_phone2, l.updated AS c_bp_location_updated, l.updatedby AS c_bp_location_updatedby, c.ad_org_id AS ad_user_ad_org_id, c.c_bpartner_id AS ad_user_c_bpartner_id, c.c_bpartner_location_id AS ad_user_c_bpartner_location_id, c.created AS ad_user_created, c.createdby AS ad_user_createdby, c.isactive AS ad_user_isactive, c.updated AS ad_user_updated, c.updatedby AS ad_user_updatedby, c.value AS ad_user_value, a.address4, a.ad_org_id AS c_location_ad_org_id, a.c_city_id, a.c_location_id, a.created AS c_location_created, a.createdby AS c_location_createdby, a.isactive AS c_location_isactive, a.postal_add, a.updated AS c_location_updated, a.updatedby AS c_location_updatedby, r.ad_org_id AS c_region_ad_org_id, r.c_country_id AS c_region_c_country_id, r.description AS c_region_description, r.isactive AS c_region_isactive, r.isdefault, cc.ad_language AS c_country_ad_language, cc.c_currency_id AS c_country_c_currency_id, cc.countrycode, cc.description AS c_country_description, cc.isactive AS c_country_isactive
FROM c_bpartner bp
LEFT JOIN c_bpartner_location l ON bp.c_bpartner_id = l.c_bpartner_id AND l.isactive = 'Y'
LEFT JOIN ad_user c ON bp.c_bpartner_id = c.c_bpartner_id AND (c.c_bpartner_location_id IS NULL OR c.c_bpartner_location_id = l.c_bpartner_location_id) AND c.isactive = 'Y'
LEFT JOIN c_location a ON l.c_location_id = a.c_location_id
LEFT JOIN c_region r ON a.c_region_id = r.c_region_id
JOIN c_country cc ON a.c_country_id = cc.c_country_id;

View File

@ -1,38 +1,12 @@
CREATE OR REPLACE VIEW RV_BPARTNEROPEN
(AD_CLIENT_ID, AD_ORG_ID, ISACTIVE, CREATED, CREATEDBY,
UPDATED, UPDATEDBY, C_BPARTNER_ID, C_CURRENCY_ID, AMT,
OPENAMT, DATEDOC, DAYSDUE, C_CAMPAIGN_ID, C_PROJECT_ID,
C_ACTIVITY_ID)
AS
SELECT i.AD_Client_ID,i.AD_Org_ID, i.IsActive, i.Created,i.CreatedBy,i.Updated,i.UpdatedBy,
i.C_BPartner_ID, i.C_Currency_ID,
i.GrandTotal*i.MultiplierAP AS Amt,
invoiceOpen (i.C_Invoice_ID, i.C_InvoicePaySchedule_ID)*i.MultiplierAP AS OpenAmt,
i.DateInvoiced AS DateDoc,
COALESCE(daysBetween(getdate(),ips.DueDate), paymentTermDueDays(C_PaymentTerm_ID,DateInvoiced,getdate())) AS DaysDue,
i.C_Campaign_ID, i.C_Project_ID, i.C_Activity_ID
FROM C_Invoice_v i
LEFT OUTER JOIN C_InvoicePaySchedule ips ON (i.C_InvoicePaySchedule_ID=ips.C_InvoicePaySchedule_ID)
WHERE i.IsPaid='N'
AND i.DocStatus IN ('CO','CL')
UNION
SELECT p.AD_Client_ID,p.AD_Org_ID, p.IsActive, p.Created,p.CreatedBy,p.Updated,p.UpdatedBy,
p.C_BPartner_ID, p.C_Currency_ID,
p.PayAmt*MultiplierAP*-1 AS Amt,
paymentAvailable(p.C_Payment_ID)*p.MultiplierAP*-1 AS OpenAmt,
p.DateTrx AS DateDoc,
null,
p.C_Campaign_ID, p.C_Project_ID, p.C_Activity_ID
FROM C_Payment_v p
WHERE p.IsAllocated='N' AND p.C_BPartner_ID IS NOT NULL
AND p.DocStatus IN ('CO','CL');
DROP VIEW rv_bpartneropen;
CREATE OR REPLACE VIEW rv_bpartneropen AS
SELECT i.ad_client_id, i.ad_org_id, i.isactive, i.created, i.createdby, i.updated, i.updatedby, i.c_bpartner_id, i.c_currency_id, i.grandtotal * i.multiplierap AS amt, invoiceopen(i.c_invoice_id, i.c_invoicepayschedule_id) * i.multiplierap AS openamt, i.dateinvoiced AS datedoc, COALESCE(daysbetween(getdate(), ips.duedate), paymenttermduedays(i.c_paymentterm_id, i.dateinvoiced, getdate())) AS daysdue, i.c_campaign_id, i.c_project_id, i.c_activity_id, i.ad_orgtrx_id, i.c_charge_id, i.c_conversiontype_id, i.c_doctype_id, i.chargeamt, i.c_invoice_id, i.c_order_id, i.c_payment_id, i.dateacct, i.description, i.docstatus, i.documentno, i.isapproved, i.isselfservice, i.posted, i.processedon, i.reversal_id
FROM c_invoice_v i
LEFT JOIN c_invoicepayschedule ips ON i.c_invoicepayschedule_id = ips.c_invoicepayschedule_id
WHERE i.ispaid = 'N' AND i.docstatus IN ('CO', 'CL')
UNION
SELECT p.ad_client_id, p.ad_org_id, p.isactive, p.created, p.createdby, p.updated, p.updatedby, p.c_bpartner_id, p.c_currency_id, p.payamt * p.multiplierap * (-1) AS amt, paymentavailable(p.c_payment_id) * p.multiplierap * (-1) AS openamt, p.datetrx AS datedoc, NULL AS daysdue, p.c_campaign_id, p.c_project_id, p.c_activity_id, p.ad_orgtrx_id, p.c_charge_id, p.c_conversiontype_id, p.c_doctype_id, p.chargeamt, p.c_invoice_id, p.c_order_id, p.c_payment_id, p.dateacct, p.description, p.docstatus, p.documentno, p.isapproved, p.isselfservice, p.posted, p.processedon, p.reversal_id
FROM c_payment_v p
WHERE p.isallocated = 'N' AND p.c_bpartner_id IS NOT NULL AND p.docstatus IN ('CO', 'CL');

File diff suppressed because one or more lines are too long

View File

@ -1,22 +1,9 @@
CREATE OR REPLACE VIEW RV_COST
(AD_CLIENT_ID, AD_ORG_ID, ISACTIVE, CREATED, CREATEDBY,
UPDATED, UPDATEDBY, M_PRODUCT_ID, VALUE, NAME,
UPC, ISBOM, PRODUCTTYPE, M_PRODUCT_CATEGORY_ID, M_COSTTYPE_ID,
M_COSTELEMENT_ID, COSTELEMENTTYPE, COSTINGMETHOD, ISCALCULATED, C_ACCTSCHEMA_ID,
C_CURRENCY_ID, CURRENTCOSTPRICE, FUTURECOSTPRICE, DESCRIPTION,
CURRENTCOSTPRICELL, FUTURECOSTPRICELL, ISCOSTFROZEN)
AS
SELECT c.AD_Client_ID, c.AD_Org_ID, c.IsActive, c.Created,c.CreatedBy,c.Updated,c.UpdatedBy,
p.M_Product_ID, p.Value, p.Name, p.UPC, p.IsBOM, p.ProductType, p.M_Product_Category_ID,
c.M_CostType_ID,
ce.M_CostElement_ID, ce.CostElementType, ce.CostingMethod, ce.IsCalculated,
acct.C_AcctSchema_ID, acct.C_Currency_ID,
c.CurrentCostPrice, c.FutureCostPrice, c.Description,
c.CurrentCostPriceLL, c.FutureCostPriceLL, c.IsCostFrozen
FROM M_Cost c
INNER JOIN M_Product p ON (c.M_Product_ID=p.M_Product_ID)
INNER JOIN M_CostElement ce ON (c.M_CostElement_ID=ce.M_CostElement_ID)
INNER JOIN C_AcctSchema acct ON (c.C_AcctSchema_ID=acct.C_AcctSchema_ID);
DROP VIEW rv_cost;
CREATE OR REPLACE VIEW rv_cost AS
SELECT c.ad_client_id, c.ad_org_id, c.isactive, c.created, c.createdby, c.updated, c.updatedby, p.m_product_id, p.value, p.name, p.upc, p.isbom, p.producttype, p.m_product_category_id, c.m_costtype_id, ce.m_costelement_id, ce.costelementtype, ce.costingmethod, ce.iscalculated, acct.c_acctschema_id, acct.c_currency_id, c.currentcostprice, c.futurecostprice, c.description, c.currentcostpricell, c.futurecostpricell, c.iscostfrozen, c.cumulatedamt, c.cumulatedqty, c.currentqty, c.m_attributesetinstance_id, c.percent, p.ad_org_id AS m_product_ad_org_id, p.classification, p.copyfrom AS m_product_copyfrom, p.created AS m_product_created, p.createdby AS m_product_createdby, p.c_revenuerecognition_id, p.c_subscriptiontype_id, p.c_taxcategory_id, p.c_uom_id, p.description AS m_product_description, p.descriptionurl, p.discontinued, p.discontinuedat, p.documentnote, p.group1, p.group2, p.guaranteedays, p.guaranteedaysmin, p.help, p.imageurl, p.isactive AS m_product_isactive, p.isdropship, p.isexcludeautodelivery, p.isinvoiceprintdetails, p.ispicklistprintdetails, p.ispurchased, p.isselfservice, p.issold, p.isstocked, p.issummary AS m_product_issummary, p.isverified, p.iswebstorefeatured, p.lowlevel, p.m_attributeset_id AS m_product_m_attributeset_id, p.m_attributesetinstance_id AS m_product_m_attributesetinsta, p.m_freightcategory_id, p.m_locator_id, p.processing AS m_product_processing, p.r_mailtext_id, p.salesrep_id AS m_product_salesrep_id, p.s_expensetype_id, p.shelfdepth, p.shelfheight, p.shelfwidth, p.sku, p.s_resource_id, p.unitsperpack, p.unitsperpallet, p.updated AS m_product_updated, p.updatedby AS m_product_updatedby, p.versionno, p.volume, p.weight, ce.ad_org_id AS m_costelement_ad_org_id, ce.description AS m_costelement_description, ce.isactive AS m_costelement_isactive, ce.name AS m_costelement_name, acct.ad_org_id AS c_acctschema_ad_org_id, acct.description AS c_acctschema_description, acct.name AS c_acctschema_name
FROM m_cost c
JOIN m_product p ON c.m_product_id = p.m_product_id
JOIN m_costelement ce ON c.m_costelement_id = ce.m_costelement_id
JOIN c_acctschema acct ON c.c_acctschema_id = acct.c_acctschema_id;

View File

@ -1,21 +1,9 @@
CREATE OR REPLACE VIEW RV_COSTDETAIL
(AD_CLIENT_ID, AD_ORG_ID, ISACTIVE, CREATED, CREATEDBY,
UPDATED, UPDATEDBY, M_PRODUCT_ID, VALUE, NAME,
UPC, ISBOM, PRODUCTTYPE, M_PRODUCT_CATEGORY_ID, M_INOUTLINE_ID,
C_INVOICELINE_ID, M_ATTRIBUTESETINSTANCE_ID, M_ATTRIBUTESET_ID, LOT, SERNO,
C_ACCTSCHEMA_ID, C_CURRENCY_ID, AMT, QTY, DESCRIPTION,
PROCESSED)
AS
SELECT c.AD_Client_ID, c.AD_Org_ID, c.IsActive, c.Created,c.CreatedBy,c.Updated,c.UpdatedBy,
p.M_Product_ID, p.Value, p.Name, p.UPC, p.IsBOM, p.ProductType, p.M_Product_Category_ID,
c.M_InOutLine_ID, c.C_InvoiceLine_ID,
asi.M_AttributeSetInstance_ID, asi.M_AttributeSet_ID, asi.Lot, asi.SerNo,
acct.C_AcctSchema_ID, acct.C_Currency_ID,
c.Amt, c.Qty, c.Description, Processed
FROM M_CostDetail c
INNER JOIN M_Product p ON (c.M_Product_ID=p.M_Product_ID)
INNER JOIN C_AcctSchema acct ON (c.C_AcctSchema_ID=acct.C_AcctSchema_ID)
INNER JOIN M_AttributeSetInstance asi ON (c.M_AttributeSetInstance_ID=asi.M_AttributeSetInstance_ID);
DROP VIEW rv_costdetail;
CREATE OR REPLACE VIEW rv_costdetail AS
SELECT c.ad_client_id, c.ad_org_id, c.isactive, c.created, c.createdby, c.updated, c.updatedby, p.m_product_id, p.value, p.name, p.upc, p.isbom, p.producttype, p.m_product_category_id, c.m_inoutline_id, c.c_invoiceline_id, asi.m_attributesetinstance_id, asi.m_attributeset_id, asi.lot, asi.serno, acct.c_acctschema_id, acct.c_currency_id, c.amt, c.qty, c.description, c.processed, c.c_orderline_id, c.c_projectissue_id, c.cumulatedamt, c.cumulatedqty, c.currentcostprice, c.currentqty, c.deltaamt, c.deltaqty, c.issotrx, c.m_costdetail_id, c.m_costelement_id, c.m_inventoryline_id, c.m_movementline_id, c.m_productionline_id, c.pp_cost_collector_id, p.ad_org_id AS m_product_ad_org_id, p.classification, p.copyfrom AS m_product_copyfrom, p.created AS m_product_created, p.createdby AS m_product_createdby, p.c_revenuerecognition_id, p.c_subscriptiontype_id, p.c_taxcategory_id, p.c_uom_id, p.description AS m_product_description, p.descriptionurl, p.discontinued, p.discontinuedat, p.documentnote, p.group1, p.group2, p.guaranteedays, p.guaranteedaysmin, p.help, p.imageurl, p.isactive AS m_product_isactive, p.isdropship, p.isexcludeautodelivery, p.isinvoiceprintdetails, p.ispicklistprintdetails, p.ispurchased, p.isselfservice, p.issold, p.isstocked, p.issummary AS m_product_issummary, p.isverified, p.iswebstorefeatured, p.lowlevel, p.m_attributeset_id AS m_product_m_attributeset_id, p.m_attributesetinstance_id AS m_product_m_asi_id, p.m_freightcategory_id, p.m_locator_id, p.processing AS m_product_processing, p.r_mailtext_id, p.salesrep_id AS m_product_salesrep_id, p.s_expensetype_id, p.shelfdepth, p.shelfheight, p.shelfwidth, p.sku, p.s_resource_id, p.unitsperpack, p.unitsperpallet, p.updated AS m_product_updated, p.updatedby AS m_product_updatedby, p.versionno, p.volume, p.weight, acct.ad_org_id AS c_acctschema_ad_org_id, acct.description AS c_acctschema_description, acct.name AS c_acctschema_name, asi.ad_org_id AS m_asi_ad_org_id, asi.created AS m_asi_created, asi.createdby AS m_asi_createdby, asi.description AS m_asi_description, asi.guaranteedate, asi.isactive AS m_asi_isactive, asi.m_lot_id, asi.updated AS m_asi_updated, asi.updatedby AS m_asi_updatedby
FROM m_costdetail c
JOIN m_product p ON c.m_product_id = p.m_product_id
JOIN c_acctschema acct ON c.c_acctschema_id = acct.c_acctschema_id
JOIN m_attributesetinstance asi ON c.m_attributesetinstance_id = asi.m_attributesetinstance_id;

View File

@ -1,38 +1,24 @@
CREATE OR REPLACE VIEW RV_C_INVOICE
(C_INVOICE_ID, AD_CLIENT_ID, AD_ORG_ID, ISACTIVE, CREATED,
CREATEDBY, UPDATED, UPDATEDBY, ISSOTRX, DOCUMENTNO,
DOCSTATUS, DOCACTION, ISPRINTED, ISDISCOUNTPRINTED, PROCESSING,
PROCESSED, ISTRANSFERRED, ISPAID, C_DOCTYPE_ID, C_DOCTYPETARGET_ID,
C_ORDER_ID, DESCRIPTION, ISAPPROVED, SALESREP_ID, DATEINVOICED,
DATEPRINTED, DATEACCT, C_BPARTNER_ID, C_BPARTNER_LOCATION_ID, AD_USER_ID,
C_BP_GROUP_ID, POREFERENCE, DATEORDERED, C_CURRENCY_ID, C_CONVERSIONTYPE_ID,
PAYMENTRULE, C_PAYMENTTERM_ID, M_PRICELIST_ID, C_CAMPAIGN_ID, C_PROJECT_ID,
C_ACTIVITY_ID, ISPAYSCHEDULEVALID, INVOICECOLLECTIONTYPE, C_COUNTRY_ID, C_REGION_ID,
POSTAL, CITY, C_CHARGE_ID, CHARGEAMT, TOTALLINES,
GRANDTOTAL, MULTIPLIER)
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.IsPrinted, i.IsDiscountPrinted, i.Processing, i.Processed, i.IsTransferred, i.IsPaid,
i.C_DocType_ID, i.C_DocTypeTarget_ID, i.C_Order_ID, i.Description, i.IsApproved,
i.SalesRep_ID, i.DateInvoiced, i.DatePrinted, i.DateAcct,
i.C_BPartner_ID, i.C_BPartner_Location_ID, i.AD_User_ID, b.C_BP_Group_ID,
i.POReference, i.DateOrdered, i.C_Currency_ID, C_ConversionType_ID, i.PaymentRule, i.C_PaymentTerm_ID,
i.M_PriceList_ID, i.C_Campaign_ID, i.C_Project_ID, i.C_Activity_ID,
i.IsPayScheduleValid, i.InvoiceCollectionType,
loc.C_Country_ID, loc.C_Region_ID, loc.Postal, loc.City,
-- Amounts
i.C_Charge_ID,
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
FROM C_Invoice i
INNER JOIN C_DocType d ON (i.C_DocType_ID=d.C_DocType_ID)
INNER JOIN C_BPartner b ON (i.C_BPartner_ID=b.C_BPartner_ID)
INNER JOIN C_BPartner_Location bpl ON (i.C_BPartner_Location_ID=bpl.C_BPartner_Location_ID)
INNER JOIN C_Location loc ON (bpl.C_Location_ID=loc.C_Location_ID);
CREATE OR REPLACE VIEW rv_c_invoice 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.isprinted, i.isdiscountprinted, i.processing, i.processed, i.istransferred, i.ispaid, i.c_doctype_id, i.c_doctypetarget_id, i.c_order_id, i.description, i.isapproved, i.salesrep_id, i.dateinvoiced, i.dateprinted, i.dateacct, i.c_bpartner_id, i.c_bpartner_location_id, i.ad_user_id, b.c_bp_group_id, i.poreference, i.dateordered, i.c_currency_id, i.c_conversiontype_id, i.paymentrule, i.c_paymentterm_id, i.m_pricelist_id, i.c_campaign_id, i.c_project_id, i.c_activity_id, i.ispayschedulevalid, i.invoicecollectiontype, loc.c_country_id, loc.c_region_id, loc.postal, loc.city, i.c_charge_id,
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, i.ad_orgtrx_id AS c_invoice_ad_orgtrx_id, i.c_conversiontype_id AS c_invoice_c_conversiontype_id, i.c_dunninglevel_id, i.c_payment_id, i.dateordered AS c_invoice_dateordered, i.dunninggrace, i.generateto, i.isindispute, i.ispayschedulevalid AS c_invoice_ispayschedulevalid, i.isselfservice AS c_invoice_isselfservice, i.istaxincluded, i.m_rma_id, i.posted, i.processedon, i.ref_invoice_id, i.reversal_id, i.sendemail, i.user1_id, i.user2_id, b.acqusitioncost AS c_bp_acqusitioncost, b.actuallifetimevalue AS c_bp_actuallifetimevalue, b.ad_language AS c_bp_ad_language, b.ad_orgbp_id AS c_bp_ad_orgbp_id, b.ad_org_id AS c_bp_ad_org_id, b.bpartner_parent_id AS c_bp_bpartner_parent_id, b.c_dunning_id AS c_bp_c_dunning_id, b.c_greeting_id AS c_bp_c_greeting_id, b.c_invoiceschedule_id AS c_bp_c_invoiceschedule_id, b.c_paymentterm_id AS c_bp_c_paymentterm_id, b.created AS c_bp_created, b.createdby AS c_bp_createdby, b.c_taxgroup_id AS c_bp_c_taxgroup_id, b.deliveryrule AS c_bp_deliveryrule, b.deliveryviarule AS c_bp_deliveryviarule, b.description AS c_bp_description, b.dunninggrace AS c_bp_dunninggrace, b.duns AS c_bp_duns, b.firstsale AS c_bp_firstsale, b.flatdiscount AS c_bp_flatdiscount, b.freightcostrule AS c_bp_freightcostrule, b.invoicerule AS c_bp_invoicerule, b.isactive AS c_bp_isactive, b.iscustomer AS c_bp_iscustomer, b.isdiscountprinted AS c_bp_isdiscountprinted, b.isemployee AS c_bp_isemployee, b.ismanufacturer AS c_bp_ismanufacturer, b.isonetime AS c_bp_isonetime, b.ispotaxexempt AS c_bp_ispotaxexempt, b.isprospect AS c_bp_isprospect, b.issalesrep AS c_bp_issalesrep, b.issummary AS c_bp_issummary, b.istaxexempt AS c_bp_istaxexempt, b.isvendor AS c_bp_isvendor, b.logo_id AS c_bp_logo_id, b.m_discountschema_id AS c_bp_m_discountschema_id, b.m_pricelist_id AS c_bp_m_pricelist_id, b.naics AS c_bp_naics, b.name AS c_bp_name, b.name2 AS c_bp_name2, b.numberemployees AS c_bp_numberemployees, b.paymentrule AS c_bp_paymentrule, b.paymentrulepo AS c_bp_paymentrulepo, b.po_discountschema_id AS c_bp_po_discountschema_id, b.po_paymentterm_id AS c_bp_po_paymentterm_id, b.po_pricelist_id AS c_bp_po_pricelist_id, b.poreference AS c_bp_poreference, b.potentiallifetimevalue AS c_bp_potentiallifetimevalue, b.rating AS c_bp_rating, b.referenceno AS c_bp_referenceno, b.salesrep_id AS c_bp_salesrep_id, b.salesvolume AS c_bp_salesvolume, b.sendemail AS c_bp_sendemail, b.shareofcustomer AS c_bp_shareofcustomer, b.shelflifeminpct AS c_bp_shelflifeminpct, b.so_creditlimit AS c_bp_so_creditlimit, b.socreditstatus AS c_bp_socreditstatus, b.so_creditused AS c_bp_so_creditused, b.so_description AS c_bp_so_description, b.taxid, b.totalopenbalance AS c_bp_totalopenbalance, b.updated AS c_bp_updated, b.updatedby AS c_bp_updatedby, b.url AS c_bp_url, b.value AS c_bp_value, bpl.ad_org_id AS c_bp_location_ad_org_id, bpl.c_bpartner_id AS c_bp_location_c_bpartner_id, bpl.c_location_id AS c_bp_location_c_location_id, bpl.created AS c_bp_location_created, bpl.createdby AS c_bp_location_createdby, bpl.c_salesregion_id, bpl.fax AS c_bp_location_fax, bpl.isactive AS c_bp_location_isactive, bpl.isbillto, bpl.isdn, bpl.ispayfrom, bpl.isremitto, bpl.isshipto, bpl.name AS c_bp_location_name, bpl.phone AS c_bp_location_phone, bpl.phone2 AS c_bp_location_phone2, bpl.updated AS c_bp_location_updated, bpl.updatedby AS c_bp_location_updatedby, loc.address1, loc.address2, loc.address3, loc.address4, loc.ad_org_id AS c_location_ad_org_id, loc.c_city_id, loc.created AS c_location_created, loc.createdby AS c_location_createdby, loc.isactive AS c_location_isactive, loc.postal_add, loc.regionname, loc.updated AS c_location_updated, loc.updatedby AS c_location_updatedby
FROM c_invoice i
JOIN c_doctype d ON i.c_doctype_id = d.c_doctype_id
JOIN c_bpartner b ON i.c_bpartner_id = b.c_bpartner_id
JOIN c_bpartner_location bpl ON i.c_bpartner_location_id = bpl.c_bpartner_location_id
JOIN c_location loc ON bpl.c_location_id = loc.c_location_id;

View File

@ -1,48 +1,27 @@
CREATE OR REPLACE VIEW RV_C_INVOICELINE
(AD_CLIENT_ID, AD_ORG_ID, ISACTIVE, CREATED, CREATEDBY,
UPDATED, UPDATEDBY, C_INVOICELINE_ID, C_INVOICE_ID, SALESREP_ID,
C_BPARTNER_ID, C_BP_GROUP_ID, M_PRODUCT_ID, M_PRODUCT_CATEGORY_ID, DATEINVOICED,
DATEACCT, ISSOTRX, C_DOCTYPE_ID, DOCSTATUS, ISPAID,
C_CAMPAIGN_ID, C_PROJECT_ID, C_ACTIVITY_ID, C_PROJECTPHASE_ID, C_PROJECTTASK_ID,
QTYINVOICED, QTYENTERED, M_ATTRIBUTESETINSTANCE_ID, PRODUCTATTRIBUTE, M_ATTRIBUTESET_ID,
M_LOT_ID, GUARANTEEDATE, LOT, SERNO, PRICELIST,
PRICEACTUAL, PRICELIMIT, PRICEENTERED, DISCOUNT, MARGIN,
MARGINAMT, LINENETAMT, LINELISTAMT, LINELIMITAMT, LINEDISCOUNTAMT,
LINEOVERLIMITAMT)
AS
SELECT
il.AD_Client_ID, il.AD_Org_ID, il.IsActive, il.Created, il.CreatedBy, il.Updated, il.UpdatedBy,
il.C_InvoiceLine_ID, i.C_Invoice_ID, i.SalesRep_ID,
i.C_BPartner_ID, i.C_BP_Group_ID,
il.M_Product_ID, p.M_Product_Category_ID,
i.DateInvoiced, i.DateAcct, i.IsSOTrx, i.C_DocType_ID, i.DocStatus, i.IsPaid,
il.C_Campaign_ID, il.C_Project_ID, il.C_Activity_ID, il.C_ProjectPhase_ID, il.C_ProjectTask_ID,
-- Qty
il.QtyInvoiced*i.Multiplier AS QtyInvoiced,
il.QtyEntered*i.Multiplier AS QtyEntered,
-- Attributes
il.M_AttributeSetInstance_ID, productAttribute(il.M_AttributeSetInstance_ID) AS ProductAttribute,
pasi.M_AttributeSet_ID, pasi.M_Lot_ID, pasi.GuaranteeDate, pasi.Lot, pasi.SerNo,
-- Item Amounts
il.PriceList, il.PriceActual, il.PriceLimit, il.PriceEntered,
CASE WHEN PriceList=0 THEN 0 ELSE
ROUND((PriceList-PriceActual)/PriceList*100,2) END AS Discount,
CASE WHEN PriceLimit=0 THEN 0 ELSE
ROUND((PriceActual-PriceLimit)/PriceLimit*100,2) END AS Margin,
CASE WHEN PriceLimit=0 THEN 0 ELSE
(PriceActual-PriceLimit)*QtyInvoiced END AS MarginAmt,
-- Line Amounts
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
FROM RV_C_Invoice i
INNER JOIN C_InvoiceLine il ON (i.C_Invoice_ID=il.C_Invoice_ID)
LEFT OUTER JOIN M_Product p ON (il.M_Product_ID=p.M_Product_ID)
LEFT OUTER JOIN M_AttributeSetInstance pasi ON (il.M_AttributeSetInstance_ID=pasi.M_AttributeSetInstance_ID);
CREATE OR REPLACE VIEW rv_c_invoiceline AS
SELECT il.ad_client_id, il.ad_org_id, il.isactive, il.created, il.createdby, il.updated, il.updatedby, il.c_invoiceline_id, i.c_invoice_id, i.salesrep_id, i.c_bpartner_id, i.c_bp_group_id, il.m_product_id, p.m_product_category_id, i.dateinvoiced, i.dateacct, i.issotrx, i.c_doctype_id, i.docstatus, i.ispaid, il.c_campaign_id, il.c_project_id, il.c_activity_id, il.c_projectphase_id, il.c_projecttask_id, il.qtyinvoiced * i.multiplier AS qtyinvoiced, il.qtyentered * i.multiplier AS qtyentered, il.m_attributesetinstance_id, productattribute(il.m_attributesetinstance_id) AS productattribute, pasi.m_attributeset_id, pasi.m_lot_id, pasi.guaranteedate, pasi.lot, pasi.serno, il.pricelist, il.priceactual, il.pricelimit, 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.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 (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.a_processed, il.c_charge_id, il.c_orderline_id, il.c_tax_id, il.c_uom_id AS c_invoiceline_c_uom_id, il.description AS c_invoiceline_description, il.isdescription, il.isprinted, il.line, il.linenetamt AS c_invoiceline_linenetamt, il.linetotalamt, il.m_inoutline_id, il.m_rmaline_id, il.processed, il.ref_invoiceline_id, il.rramt, il.rrstartdate, il.s_resourceassignment_id, il.taxamt, il.user1_id, il.user2_id, p.ad_org_id AS m_product_ad_org_id, p.classification, p.copyfrom AS m_product_copyfrom, p.created AS m_product_created, p.createdby AS m_product_createdby, p.c_revenuerecognition_id, p.c_subscriptiontype_id, p.c_taxcategory_id, p.c_uom_id AS m_productline_c_uom_id, p.description AS m_product_description, p.descriptionurl, p.discontinued, p.discontinuedat, p.documentnote, p.group1, p.group2, p.guaranteedays, p.guaranteedaysmin, p.help, p.imageurl, p.isactive AS m_product_isactive, p.isdropship, p.isexcludeautodelivery, p.isinvoiceprintdetails, p.ispicklistprintdetails, p.ispurchased, p.isselfservice, p.issold, p.isstocked, p.issummary AS m_product_issummary, p.isverified, p.iswebstorefeatured, p.lowlevel, p.m_attributeset_id AS m_product_m_attributeset_id, p.m_freightcategory_id, p.m_locator_id, p.m_product_id AS m_product_m_product_id, p.processing AS m_product_processing, p.producttype, p.r_mailtext_id, p.salesrep_id AS m_product_salesrep_id, p.s_expensetype_id, p.shelfdepth, p.shelfheight, p.shelfwidth, p.sku, p.s_resource_id, p.unitsperpack, p.unitsperpallet, p.updated AS m_product_updated, p.updatedby AS m_product_updatedby, p.versionno, p.volume, p.weight, pasi.ad_org_id AS m_asi_ad_org_id, pasi.created AS m_attributesetinstance_created, pasi.createdby AS m_asi_createdby, pasi.description AS m_asi_description, pasi.isactive AS m_attributesetinstance_isacti, pasi.serno AS m_attributesetinstance_serno, pasi.updated AS m_attributesetinstance_updated, pasi.updatedby AS m_asi_updatedby
FROM rv_c_invoice i
JOIN c_invoiceline il ON i.c_invoice_id = il.c_invoice_id
LEFT JOIN m_product p ON il.m_product_id = p.m_product_id
LEFT JOIN m_attributesetinstance pasi ON il.m_attributesetinstance_id = pasi.m_attributesetinstance_id;

View File

@ -1,23 +1,25 @@
CREATE OR REPLACE VIEW RV_C_INVOICETAX
(AD_CLIENT_ID, AD_ORG_ID, ISACTIVE, CREATED, CREATEDBY,
UPDATED, UPDATEDBY, C_TAX_ID, C_INVOICE_ID, C_DOCTYPE_ID,
C_BPARTNER_ID, TAXID, ISTAXEXEMPT, DATEACCT, DATEINVOICED,
ISSOTRX, DOCUMENTNO, ISPAID, C_CURRENCY_ID, TAXBASEAMT,
TAXAMT, TAXLINETOTAL, MULTIPLIER)
AS
SELECT
i.AD_Client_ID, i.AD_Org_ID, i.IsActive, t.Created, t.CreatedBy, t.Updated, t.UpdatedBy,
t.C_Tax_ID, i.C_Invoice_ID, i.C_DocType_ID,
i.C_BPartner_ID, bp.TaxID, bp.IsTaxExempt,
i.DateAcct, i.DateInvoiced, i.IsSOTrx, i.DocumentNo, i.IsPaid, i.C_Currency_ID,
CASE WHEN charAt(d.DocBaseType,3)='C' THEN t.TaxBaseAmt*-1 ELSE t.TaxBaseAmt END AS TaxBaseAmt,
CASE WHEN charAt(d.DocBaseType,3)='C' THEN t.TaxAmt*-1 ELSE t.TaxAmt END AS TaxAmt,
CASE WHEN charAt(d.DocBaseType,3)='C' THEN (t.TaxBaseAmt + t.TaxAmt)*-1 ELSE (t.TaxBaseAmt + t.TaxAmt) END AS TaxLineTotal,
CASE WHEN charAt(d.DocBaseType,3)='C' THEN -1 ELSE 1 END AS Multiplier
FROM C_InvoiceTax t
INNER JOIN C_Invoice i ON (t.C_Invoice_ID=i.C_Invoice_ID)
INNER JOIN C_DocType d ON (i.C_DocType_ID=d.C_DocType_ID)
INNER JOIN C_BPartner bp ON (i.C_BPartner_ID=bp.C_BPartner_ID);
DROP VIEW rv_c_invoicetax;
CREATE OR REPLACE VIEW rv_c_invoicetax AS
SELECT i.ad_client_id, i.ad_org_id, i.isactive, t.created, t.createdby, t.updated, t.updatedby, t.c_tax_id, i.c_invoice_id, i.c_doctype_id, i.c_bpartner_id, bp.taxid, bp.istaxexempt, i.dateacct, i.dateinvoiced, i.issotrx, i.documentno, i.ispaid, i.c_currency_id,
CASE
WHEN charat(d.docbasetype, 3) = 'C' THEN t.taxbaseamt * (-1)
ELSE t.taxbaseamt
END AS taxbaseamt,
CASE
WHEN charat(d.docbasetype, 3) = 'C' THEN t.taxamt * (-1)
ELSE t.taxamt
END AS taxamt,
CASE
WHEN charat(d.docbasetype, 3) = 'C' THEN (t.taxbaseamt + t.taxamt) * (-1)
ELSE t.taxbaseamt + t.taxamt
END AS taxlinetotal,
CASE
WHEN charat(d.docbasetype, 3) = 'C' THEN (-1)
ELSE 1
END AS multiplier, t.ad_org_id AS c_invoicetax_ad_org_id, t.isactive AS c_invoicetax_isactive, t.istaxincluded AS c_invoicetax_istaxincluded, t.processed AS c_invoicetax_processed, i.ad_orgtrx_id AS c_invoice_ad_orgtrx_id, i.ad_user_id, i.c_bpartner_location_id, i.c_activity_id, i.c_campaign_id, i.c_charge_id, i.c_conversiontype_id, i.c_doctypetarget_id, i.c_dunninglevel_id, i.chargeamt, i.c_order_id, i.c_payment_id, i.c_paymentterm_id AS c_invoice_c_paymentterm_id, i.created AS c_invoice_created, i.createdby AS c_invoice_createdby, i.dateprinted, i.description AS c_invoice_description, i.docaction, i.docstatus, i.dunninggrace, i.generateto, i.invoicecollectiontype, i.isapproved, i.isdiscountprinted, i.isindispute, i.ispayschedulevalid, i.isprinted, i.isselfservice AS c_invoice_isselfservice, i.istaxincluded AS c_invoice_istaxincluded, i.istransferred, i.m_pricelist_id, i.m_rma_id, i.paymentrule, i.poreference AS c_invoice_poreference, i.posted, i.processedon, i.processing, i.ref_invoice_id, i.reversal_id, i.salesrep_id, i.sendemail, i.totallines, i.updated AS c_invoice_updated, i.updatedby AS c_invoice_updatedby, i.user1_id, i.user2_id, bp.acqusitioncost AS c_bp_acqusitioncost, bp.actuallifetimevalue AS c_bp_actuallifetimevalue, bp.ad_language AS c_bp_ad_language, bp.ad_orgbp_id AS c_bp_ad_orgbp_id, bp.ad_org_id AS c_bp_ad_org_id, bp.bpartner_parent_id AS c_bp_bpartner_parent_id, bp.c_bp_group_id AS c_bp_c_bp_group_id, bp.c_dunning_id AS c_bp_c_dunning_id, bp.c_greeting_id AS c_bp_c_greeting_id, bp.c_invoiceschedule_id AS c_bp_c_invoiceschedule_id, bp.c_paymentterm_id AS c_bp_c_paymentterm_id, bp.created AS c_bp_created, bp.createdby AS c_bp_createdby, bp.c_taxgroup_id AS c_bp_c_taxgroup_id, bp.deliveryrule AS c_bp_deliveryrule, bp.deliveryviarule AS c_bp_deliveryviarule, bp.description AS c_bp_description, bp.dunninggrace AS c_bp_dunninggrace, bp.duns, bp.firstsale AS c_bp_firstsale, bp.flatdiscount AS c_bp_flatdiscount, bp.freightcostrule AS c_bp_freightcostrule, bp.invoicerule AS c_bp_invoicerule, bp.isactive AS c_bp_isactive, bp.iscustomer AS c_bp_iscustomer, bp.isdiscountprinted AS c_bp_isdiscountprinted, bp.isemployee AS c_bp_isemployee, bp.ismanufacturer AS c_bp_ismanufacturer, bp.isonetime AS c_bp_isonetime, bp.ispotaxexempt AS c_bp_ispotaxexempt, bp.isprospect AS c_bp_isprospect, bp.issalesrep AS c_bp_issalesrep, bp.issummary AS c_bp_issummary, bp.isvendor, bp.logo_id AS c_bp_logo_id, bp.m_discountschema_id, bp.m_pricelist_id AS c_bp_m_pricelist_id, bp.naics, bp.name AS c_bp_name, bp.name2 AS c_bp_name2, bp.numberemployees, bp.paymentrule AS c_bp_paymentrule, bp.paymentrulepo AS c_bp_paymentrulepo, bp.po_discountschema_id, bp.po_paymentterm_id, bp.po_pricelist_id, bp.poreference AS c_bp_poreference, bp.potentiallifetimevalue, bp.rating AS c_bp_rating, bp.salesrep_id AS c_bp_salesrep_id, bp.salesvolume, bp.sendemail AS c_bp_sendemail, bp.shareofcustomer, bp.shelflifeminpct, bp.so_creditlimit, bp.socreditstatus, bp.so_creditused, bp.so_description, bp.totalopenbalance AS c_bp_totalopenbalance, bp.updated AS c_bp_updated, bp.updatedby AS c_bp_updatedby, bp.url AS c_bp_url, bp.value AS c_bp_value
FROM c_invoicetax t
JOIN c_invoice i ON t.c_invoice_id = i.c_invoice_id
JOIN c_doctype d ON i.c_doctype_id = d.c_doctype_id
JOIN c_bpartner bp ON i.c_bpartner_id = bp.c_bpartner_id;

View File

@ -1,42 +1,12 @@
CREATE OR REPLACE VIEW RV_FACT_ACCT
(AD_CLIENT_ID, AD_ORG_ID, ISACTIVE, CREATED, CREATEDBY,
UPDATED, UPDATEDBY, FACT_ACCT_ID, C_ACCTSCHEMA_ID, ACCOUNT_ID,
DATETRX, DATEACCT, C_PERIOD_ID, AD_TABLE_ID, RECORD_ID,
LINE_ID, GL_CATEGORY_ID, GL_BUDGET_ID, C_TAX_ID, M_LOCATOR_ID,
POSTINGTYPE, C_CURRENCY_ID, AMTSOURCEDR, AMTSOURCECR, AMTSOURCE,
AMTACCTDR, AMTACCTCR, AMTACCT, RATE, C_UOM_ID,
QTY, M_PRODUCT_ID, C_BPARTNER_ID, AD_ORGTRX_ID, C_LOCFROM_ID,
C_LOCTO_ID, C_SALESREGION_ID, C_PROJECT_ID, C_CAMPAIGN_ID, C_ACTIVITY_ID,
USER1_ID, USER2_ID, A_ASSET_ID, DESCRIPTION, ORGVALUE,
ORGNAME, ACCOUNTVALUE, NAME, ACCOUNTTYPE, BPARTNERVALUE,
BPNAME, C_BP_GROUP_ID, PRODUCTVALUE, PRODUCTNAME, UPC,
M_PRODUCT_CATEGORY_ID)
AS
SELECT f.AD_Client_ID, f.AD_Org_ID, f.IsActive,f.Created,f.CreatedBy,f.Updated,f.UpdatedBy,
f.Fact_Acct_ID,
f.C_AcctSchema_ID, f.Account_ID, f.DateTrx, f.DateAcct, f.C_Period_ID,
f.AD_Table_ID, f.Record_ID, f.Line_ID,
f.GL_Category_ID, f.GL_Budget_ID, f.C_Tax_ID, f.M_Locator_ID,
f.PostingType, f.C_Currency_ID,
f.AmtSourceDr, f.AmtSourceCr, (f.AmtSourceDr - f.AmtSourceCr) AS AmtSource,
f.AmtAcctDr, f.AmtAcctCr, (f.AmtAcctDr - f.AmtAcctCr) AS AmtAcct,
CASE WHEN (f.AmtSourceDr - f.AmtSourceCr) = 0 THEN 0 ELSE
(f.AmtAcctDr - f.AmtAcctCr) / (f.AmtSourceDr - f.AmtSourceCr) END AS Rate,
f.C_UOM_ID, f.Qty,
f.M_Product_ID, f.C_BPartner_ID, f.AD_OrgTrx_ID,
f.C_LocFrom_ID, f.C_LocTo_ID, f.C_SalesRegion_ID,
f.C_Project_ID, f.C_Campaign_ID, f.C_Activity_ID,
f.User1_ID, f.User2_ID, f.A_Asset_ID,
f.Description,
o.Value AS OrgValue, o.Name AS OrgName,
ev.Value AS AccountValue, ev.Name, ev.AccountType,
bp.Value AS BPartnerValue, bp.Name AS BPName, bp.C_BP_Group_ID,
p.Value AS ProductValue, p.Name AS ProductName, p.UPC, p.M_Product_Category_ID
FROM Fact_Acct f
INNER JOIN AD_Org o ON (f.AD_Org_ID=o.AD_Org_ID)
INNER JOIN C_ElementValue ev ON (f.Account_ID=ev.C_ElementValue_ID)
LEFT OUTER JOIN C_BPartner bp ON (f.C_BPartner_ID=bp.C_BPartner_ID)
LEFT OUTER JOIN M_Product p ON (f.M_Product_ID=p.M_Product_ID);
CREATE OR REPLACE VIEW rv_fact_acct AS
SELECT f.ad_client_id, f.ad_org_id, f.isactive, f.created, f.createdby, f.updated, f.updatedby, f.fact_acct_id, f.c_acctschema_id, f.account_id, f.datetrx, f.dateacct, f.c_period_id, f.ad_table_id, f.record_id, f.line_id, f.gl_category_id, f.gl_budget_id, f.c_tax_id, f.m_locator_id, f.postingtype, f.c_currency_id, f.amtsourcedr, f.amtsourcecr, f.amtsourcedr - f.amtsourcecr AS amtsource, f.amtacctdr, f.amtacctcr, f.amtacctdr - f.amtacctcr AS amtacct,
CASE
WHEN (f.amtsourcedr - f.amtsourcecr) = 0 THEN 0
ELSE (f.amtacctdr - f.amtacctcr) / (f.amtsourcedr - f.amtsourcecr)
END AS rate, f.c_uom_id, f.qty, f.m_product_id, f.c_bpartner_id, f.ad_orgtrx_id, f.c_locfrom_id, f.c_locto_id, f.c_salesregion_id, f.c_project_id, f.c_campaign_id, f.c_activity_id, f.user1_id, f.user2_id, f.a_asset_id, f.description, o.value AS orgvalue, o.name AS orgname, ev.value AS accountvalue, ev.name, ev.accounttype, bp.value AS bpartnervalue, bp.name AS bpname, bp.c_bp_group_id, p.value AS productvalue, p.name AS productname, p.upc, p.m_product_category_id, f.c_projectphase_id, f.c_projecttask_id, f.c_subacct_id, f.userelement1_id, f.userelement2_id, o.description AS ad_org_description, o.isactive AS ad_org_isactive, ev.ad_org_id AS c_elementvalue_ad_org_id, ev.c_bankaccount_id, ev.c_currency_id AS c_elementvalue_c_currency_id, ev.c_element_id, ev.c_elementvalue_id, ev.description AS c_elementvalue_description, ev.isactive AS c_elementvalue_isactive, ev.isbankaccount, ev.isforeigncurrency, ev.issummary AS c_elementvalue_issummary, bp.acqusitioncost AS c_bp_acqusitioncost, bp.actuallifetimevalue AS c_bp_actuallifetimevalue, bp.ad_language AS c_bp_ad_language, bp.ad_orgbp_id AS c_bp_ad_orgbp_id, bp.ad_org_id AS c_bp_ad_org_id, bp.bpartner_parent_id AS c_bp_bpartner_parent_id, bp.c_dunning_id AS c_bp_c_dunning_id, bp.c_greeting_id AS c_bp_c_greeting_id, bp.c_invoiceschedule_id AS c_bp_c_invoiceschedule_id, bp.c_paymentterm_id AS c_bp_c_paymentterm_id, bp.created AS c_bp_created, bp.createdby AS c_bp_createdby, bp.c_taxgroup_id AS c_bp_c_taxgroup_id, bp.deliveryrule AS c_bp_deliveryrule, bp.deliveryviarule AS c_bp_deliveryviarule, bp.description AS c_bp_description, bp.dunninggrace AS c_bp_dunninggrace, bp.duns, bp.firstsale AS c_bp_firstsale, bp.flatdiscount AS c_bp_flatdiscount, bp.freightcostrule AS c_bp_freightcostrule, bp.invoicerule AS c_bp_invoicerule, bp.isactive AS c_bp_isactive, bp.iscustomer AS c_bp_iscustomer, bp.isdiscountprinted AS c_bp_isdiscountprinted, bp.isemployee AS c_bp_isemployee, bp.ismanufacturer AS c_bp_ismanufacturer, bp.isonetime AS c_bp_isonetime, bp.ispotaxexempt AS c_bp_ispotaxexempt, bp.isprospect AS c_bp_isprospect, bp.issalesrep AS c_bp_issalesrep, bp.issummary AS c_bp_issummary, bp.istaxexempt AS c_bp_istaxexempt, bp.isvendor AS c_bp_isvendor, bp.logo_id AS c_bp_logo_id, bp.m_discountschema_id AS c_bp_m_discountschema_id, bp.m_pricelist_id AS c_bp_m_pricelist_id, bp.naics, bp.name2 AS c_bp_name2, bp.numberemployees AS c_bp_numberemployees, bp.paymentrule AS c_bp_paymentrule, bp.paymentrulepo AS c_bp_paymentrulepo, bp.po_discountschema_id AS c_bp_po_discountschema_id, bp.po_paymentterm_id AS c_bp_po_paymentterm_id, bp.po_pricelist_id AS c_bp_po_pricelist_id, bp.poreference AS c_bp_poreference, bp.potentiallifetimevalue AS c_bp_potentiallifetimevalue, bp.rating AS c_bp_rating, bp.referenceno, bp.salesrep_id AS c_bp_salesrep_id, bp.salesvolume AS c_bp_salesvolume, bp.sendemail AS c_bp_sendemail, bp.shareofcustomer AS c_bp_shareofcustomer, bp.shelflifeminpct AS c_bp_shelflifeminpct, bp.so_creditlimit AS c_bp_so_creditlimit, bp.socreditstatus AS c_bp_socreditstatus, bp.so_creditused AS c_bp_so_creditused, bp.so_description AS c_bp_so_description, bp.taxid, bp.totalopenbalance AS c_bp_totalopenbalance, bp.updated AS c_bp_updated, bp.updatedby AS c_bp_updatedby, bp.url AS c_bp_url, p.ad_org_id AS m_product_ad_org_id, p.classification, p.copyfrom AS m_product_copyfrom, p.created AS m_product_created, p.createdby AS m_product_createdby, p.c_revenuerecognition_id, p.c_subscriptiontype_id, p.c_taxcategory_id, p.c_uom_id AS m_product_c_uom_id, p.description AS m_product_description, p.descriptionurl, p.discontinued, p.discontinuedat, p.documentnote, p.group1, p.group2, p.guaranteedays, p.guaranteedaysmin, p.help, p.imageurl, p.isactive AS m_product_isactive, p.isdropship, p.isexcludeautodelivery, p.isinvoiceprintdetails, p.ispicklistprintdetails, p.ispurchased, p.isselfservice, p.issold, p.isstocked, p.issummary AS m_product_issummary, p.isverified, p.iswebstorefeatured, p.lowlevel, p.m_attributeset_id AS m_product_m_attributeset_id, p.m_attributesetinstance_id AS m_product_m_asi_id, p.m_freightcategory_id, p.m_locator_id AS m_product_m_locator_id, p.processing AS m_product_processing, p.producttype, p.r_mailtext_id, p.salesrep_id AS m_product_salesrep_id, p.s_expensetype_id, p.shelfdepth, p.shelfheight, p.shelfwidth, p.sku, p.s_resource_id, p.unitsperpack, p.unitsperpallet, p.updated AS m_product_updated, p.updatedby AS m_product_updatedby, p.versionno, p.volume, p.weight
FROM fact_acct f
JOIN ad_org o ON f.ad_org_id = o.ad_org_id
JOIN c_elementvalue ev ON f.account_id = ev.c_elementvalue_id
LEFT JOIN c_bpartner bp ON f.c_bpartner_id = bp.c_bpartner_id
LEFT JOIN m_product p ON f.m_product_id = p.m_product_id;

View File

@ -1,47 +1,9 @@
CREATE OR REPLACE VIEW RV_INOUTDETAILS
(AD_CLIENT_ID, AD_ORG_ID, ISACTIVE, CREATED, CREATEDBY,
UPDATED, UPDATEDBY, M_INOUT_ID, ISSOTRX, DOCUMENTNO,
DOCACTION, DOCSTATUS, POSTED, PROCESSED, C_DOCTYPE_ID,
DESCRIPTION, C_ORDER_ID, DATEORDERED, MOVEMENTTYPE, MOVEMENTDATE,
DATEACCT, C_BPARTNER_ID, C_BPARTNER_LOCATION_ID, AD_USER_ID, SALESREP_ID,
M_WAREHOUSE_ID, POREFERENCE, DELIVERYRULE, FREIGHTCOSTRULE, FREIGHTAMT,
DELIVERYVIARULE, M_SHIPPER_ID, PRIORITYRULE, DATEPRINTED, NOPACKAGES,
PICKDATE, SHIPDATE, TRACKINGNO, AD_ORGTRX_ID, C_PROJECT_ID,
C_CAMPAIGN_ID, C_ACTIVITY_ID, USER1_ID, USER2_ID, DATERECEIVED,
ISAPPROVED, ISINDISPUTE, M_INOUTLINE_ID, LINE, LINEDESCRIPTION,
C_ORDERLINE_ID, M_LOCATOR_ID, M_PRODUCT_ID, C_UOM_ID, M_ATTRIBUTESETINSTANCE_ID,
PRODUCTATTRIBUTE, M_ATTRIBUTESET_ID, M_LOT_ID, GUARANTEEDATE, LOT,
SERNO, MOVEMENTQTY, QTYENTERED, ISDESCRIPTION, CONFIRMEDQTY,
PICKEDQTY, SCRAPPEDQTY, TARGETQTY, LOCATORVALUE, X,
Y, Z)
AS
SELECT h.AD_Client_ID, h.AD_Org_ID, l.IsActive, l.Created, l.CreatedBy, l.Updated, l.UpdatedBy,
h.M_InOut_ID,
h.IsSOTrx, h.DocumentNo, h.DocAction, h.DocStatus, h.Posted, h.Processed,
h.C_DocType_ID, h.Description, h.C_Order_ID, h.DateOrdered,
h.MovementType, h.MovementDate, h.DateAcct,
h.C_BPartner_ID, h.C_BPartner_Location_ID, h.AD_User_ID,
h.SalesRep_ID,
h.M_Warehouse_ID,
h.POReference, h.DeliveryRule, h.FreightCostRule, h.FreightAmt,
h.DeliveryViaRule, h.M_Shipper_ID, -- h.C_CHARGE_ID, h.CHARGEAmt,
h.PriorityRule, h.DatePrinted,
h.NoPackages, h.PickDate, h.ShipDate, h.TrackingNo,
h.AD_OrgTrx_ID, h.C_Project_ID, h.C_Campaign_ID, h.C_Activity_ID, h.User1_ID, h.User2_ID,
h.DateReceived, h.IsApproved, h.IsInDispute,
l.M_InOutLine_ID, l.Line, l.Description AS LineDescription,
l.C_OrderLine_ID, l.M_Locator_ID,
l.M_Product_ID, l.C_UOM_ID,
l.M_AttributeSetInstance_ID, productAttribute(l.M_AttributeSetInstance_ID) AS ProductAttribute,
pasi.M_AttributeSet_ID, pasi.M_Lot_ID, pasi.GuaranteeDate, pasi.Lot, pasi.SerNo,
l.MovementQty, l.QtyEntered,
l.IsDescription,
l.ConfirmedQty, l.PickedQty, l.ScrappedQty, l.TargetQty,
loc.Value AS LocatorValue, loc.X, loc.Y, loc.Z
FROM M_InOut h
INNER JOIN M_InOutLine l ON (h.M_InOut_ID=l.M_InOut_ID)
LEFT OUTER JOIN M_Locator loc ON (l.M_Locator_ID=loc.M_Locator_ID)
LEFT OUTER JOIN M_AttributeSetInstance pasi ON (l.M_AttributeSetInstance_ID=pasi.M_AttributeSetInstance_ID);
DROP VIEW rv_inoutdetails;
CREATE OR REPLACE VIEW rv_inoutdetails AS
SELECT h.ad_client_id, h.ad_org_id, l.isactive, l.created, l.createdby, l.updated, l.updatedby, h.m_inout_id, h.issotrx, h.documentno, h.docaction, h.docstatus, h.posted, h.processed, h.c_doctype_id, h.description, h.c_order_id, h.dateordered, h.movementtype, h.movementdate, h.dateacct, h.c_bpartner_id, h.c_bpartner_location_id, h.ad_user_id, h.salesrep_id, h.m_warehouse_id, h.poreference, h.deliveryrule, h.freightcostrule, h.freightamt, h.deliveryviarule, h.m_shipper_id, h.priorityrule, h.dateprinted, h.nopackages, h.pickdate, h.shipdate, h.trackingno, h.ad_orgtrx_id, h.c_project_id, h.c_campaign_id, h.c_activity_id, h.user1_id, h.user2_id, h.datereceived, h.isapproved, h.isindispute, l.m_inoutline_id, l.line, l.description AS linedescription, l.c_orderline_id, l.m_locator_id, l.m_product_id, l.c_uom_id, l.m_attributesetinstance_id, productattribute(l.m_attributesetinstance_id) AS productattribute, pasi.m_attributeset_id, pasi.m_lot_id, pasi.guaranteedate, pasi.lot, pasi.serno, l.movementqty, l.qtyentered, l.isdescription, l.confirmedqty, l.pickedqty, l.scrappedqty, l.targetqty, loc.value AS locatorvalue, loc.x, loc.y, loc.z, h.c_charge_id AS m_inout_c_charge_id, h.chargeamt, h.c_invoice_id AS m_inout_c_invoice_id, h.createconfirm, h.created AS m_inout_created, h.createdby AS m_inout_createdby, h.createfrom, h.createpackage, h.dropship_bpartner_id, h.dropship_location_id, h.dropship_user_id, h.generateto, h.isactive AS m_inout_isactive, h.isdropship, h.isintransit, h.isprinted, h.m_rma_id, h.processedon, h.processing, h.ref_inout_id, h.reversal_id, h.sendemail, h.updated AS m_inout_updated, h.updatedby AS m_inout_updatedby, h.volume, h.weight, l.ad_org_id AS m_inoutline_ad_org_id, l.ad_orgtrx_id AS m_inoutline_ad_orgtrx_id, l.c_activity_id AS m_inoutline_c_activity_id, l.c_campaign_id AS m_inoutline_c_campaign_id, l.c_charge_id AS m_inoutline_c_charge_id, l.c_project_id AS m_inoutline_c_project_id, l.c_projectphase_id, l.c_projecttask_id, l.isinvoiced, l.m_rmaline_id, l.processed AS m_inoutline_processed, l.ref_inoutline_id, l.reversalline_id, l.user1_id AS m_inoutline_user1_id, l.user2_id AS m_inoutline_user2_id, loc.ad_org_id AS m_locator_ad_org_id, loc.isactive AS m_locator_isactive, loc.isdefault, loc.m_warehouse_id AS m_locator_m_warehouse_id, loc.priorityno, pasi.ad_org_id AS m_asi_ad_org_id, pasi.created AS m_asi_created, pasi.createdby AS m_asi_createdby, pasi.description AS m_asi_description, pasi.isactive AS m_asi_isactive, pasi.updated AS m_asi_updated, pasi.updatedby AS m_asi_updatedby
FROM m_inout h
JOIN m_inoutline l ON h.m_inout_id = l.m_inout_id
LEFT JOIN m_locator loc ON l.m_locator_id = loc.m_locator_id
LEFT JOIN m_attributesetinstance pasi ON l.m_attributesetinstance_id = pasi.m_attributesetinstance_id;

View File

@ -1,16 +1,9 @@
CREATE OR REPLACE VIEW RV_M_TRANSACTION
(AD_CLIENT_ID, AD_ORG_ID, MOVEMENTDATE, MOVEMENTQTY, M_PRODUCT_ID,
M_LOCATOR_ID, M_ATTRIBUTESETINSTANCE_ID, M_PRODUCT_CATEGORY_ID, VALUE, C_BPARTNER_ID,
PRICEPO, PRICELASTPO, PRICELIST)
AS
SELECT t.AD_Client_ID,t.AD_Org_ID, t.MovementDate, t.MovementQty,
t.M_Product_ID, t.M_Locator_ID, t.M_AttributeSetInstance_ID,
p.M_Product_Category_ID, p.Value,
po.C_BPartner_ID, po.PricePO, po.PriceLastPO, po.PriceList
FROM M_Transaction t
INNER JOIN M_Product p ON (t.M_Product_ID=p.M_Product_ID)
INNER JOIN M_Product_PO po ON (t.M_Product_ID=po.M_Product_ID)
WHERE po.IsCurrentVendor='Y';
DROP VIEW rv_m_transaction;
CREATE OR REPLACE VIEW rv_m_transaction AS
SELECT t.ad_client_id, t.ad_org_id, t.movementdate, t.movementqty, t.m_product_id, t.m_locator_id, t.m_attributesetinstance_id, p.m_product_category_id, p.value, po.c_bpartner_id, po.pricepo, po.pricelastpo, po.pricelist, t.c_projectissue_id, t.created AS m_transaction_created, t.createdby AS m_transaction_createdby, t.isactive AS m_transaction_isactive, t.m_inoutline_id, t.movementtype, t.m_productionline_id, t.m_transaction_id, t.pp_cost_collector_id, t.updated AS m_transation_updated, t.updatedby AS m_transation_updatedby, p.ad_org_id AS m_product_ad_org_id, p.classification, p.copyfrom AS m_product_copyfrom, p.created AS m_product_created, p.createdby AS m_product_createdby, p.c_revenuerecognition_id, p.c_subscriptiontype_id, p.c_taxcategory_id, p.c_uom_id AS m_product_c_uom_id, p.description AS m_product_description, p.descriptionurl, p.discontinued AS m_product_discontinued, p.discontinuedat AS m_product_discontinuedat, p.documentnote, p.group1, p.group2, p.guaranteedays, p.guaranteedaysmin, p.help, p.imageurl, p.isactive AS m_product_isactive, p.isdropship, p.isexcludeautodelivery, p.isinvoiceprintdetails, p.ispicklistprintdetails, p.ispurchased, p.isselfservice, p.issold, p.isstocked, p.issummary AS m_product_issummary, p.isverified, p.iswebstorefeatured, p.lowlevel, p.m_attributeset_id AS m_product_m_attributeset_id, p.m_attributesetinstance_id AS m_product_m_asi_id, p.m_freightcategory_id, p.m_locator_id AS m_product_m_locator_id, p.name AS m_product_name, p.processing AS m_product_processing, p.producttype, p.r_mailtext_id, p.salesrep_id AS m_product_salesrep_id, p.s_expensetype_id, p.shelfdepth, p.shelfheight, p.shelfwidth, p.sku, p.s_resource_id, p.unitsperpack, p.unitsperpallet, p.upc AS m_product_upc, p.updated AS m_product_updated, p.updatedby AS m_product_updatedby, p.versionno, p.volume, p.weight, po.ad_org_id AS m_product_po_ad_org_id, po.c_currency_id AS m_product_po_c_currency_id, po.costperorder, po.created AS m_product_po_created, po.createdby AS m_product_po_createdby, po.c_uom_id AS m_product_po_c_uom_id, po.deliverytime_actual, po.deliverytime_promised, po.discontinued AS m_product_po_discontinued, po.discontinuedat AS m_product_po_discontinuedat, po.isactive AS m_product_po_isactive, po.iscurrentvendor, po.manufacturer, po.m_product_id AS m_product_po_m_product_id, po.order_min, po.order_pack, po.priceeffective, po.pricelastinv, po.qualityrating, po.royaltyamt, po.upc AS m_product_po_upc, po.updated AS m_product_po_updated, po.updatedby AS m_product_po_updatedby, po.vendorcategory, po.vendorproductno
FROM m_transaction t
JOIN m_product p ON t.m_product_id = p.m_product_id
JOIN m_product_po po ON t.m_product_id = po.m_product_id
WHERE po.iscurrentvendor = 'Y';

View File

@ -1,56 +1,13 @@
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';
DROP VIEW rv_openitem;
CREATE OR REPLACE VIEW rv_openitem 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, NULL AS c_invoicepayschedule_id, i.invoicecollectiontype, i.c_campaign_id, i.c_project_id, i.c_activity_id, i.c_invoice_ad_orgtrx_id AS ad_orgtrx_id, i.ad_user_id, i.c_bpartner_location_id, i.c_charge_id, i.c_doctype_id, i.c_doctypetarget_id, i.c_dunninglevel_id, i.chargeamt, i.c_payment_id, i.created, i.createdby, i.dateordered, i.dateprinted, i.description, i.docaction, i.docstatus, i.dunninggrace, i.generateto, i.isactive, i.isapproved, i.isdiscountprinted, i.isindispute, i.ispaid, i.isprinted, i.c_invoice_isselfservice AS isselfservice, i.istaxincluded, i.istransferred, i.m_pricelist_id, i.m_rma_id, i.paymentrule, i.poreference, i.posted, i.processedon, i.processing, i.ref_invoice_id, i.reversal_id, i.salesrep_id, i.sendemail, i.totallines, i.updated, i.updatedby, i.user1_id, i.user2_id
FROM rv_c_invoice i
JOIN c_paymentterm p ON i.c_paymentterm_id = p.c_paymentterm_id
WHERE 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, i.c_invoice_ad_orgtrx_id AS ad_orgtrx_id, i.ad_user_id, i.c_bpartner_location_id, i.c_charge_id, i.c_doctype_id, i.c_doctypetarget_id, i.c_dunninglevel_id, i.chargeamt, i.c_payment_id, i.created, i.createdby, i.dateordered, i.dateprinted, i.description, i.docaction, i.docstatus, i.dunninggrace, i.generateto, i.isactive, i.isapproved, i.isdiscountprinted, i.isindispute, i.ispaid, i.isprinted, i.c_invoice_isselfservice AS isselfservice, i.istaxincluded, i.istransferred, i.m_pricelist_id, i.m_rma_id, i.paymentrule, i.poreference, i.posted, i.processedon, i.processing, i.ref_invoice_id, i.reversal_id, i.salesrep_id, i.sendemail, i.totallines, i.updated, i.updatedby, i.user1_id, i.user2_id
FROM rv_c_invoice i
JOIN c_invoicepayschedule ips ON i.c_invoice_id = ips.c_invoice_id
WHERE invoiceopen(i.c_invoice_id, ips.c_invoicepayschedule_id) <> 0 AND i.ispayschedulevalid = 'Y' AND i.docstatus IN ('CO', 'CL') AND ips.isvalid = 'Y';

View File

@ -1,43 +1,20 @@
CREATE OR REPLACE VIEW RV_ORDERDETAIL
(AD_CLIENT_ID, AD_ORG_ID, ISACTIVE, CREATED, CREATEDBY,
UPDATED, UPDATEDBY, C_ORDER_ID, DOCSTATUS, DOCACTION,
C_DOCTYPE_ID, ISAPPROVED, ISCREDITAPPROVED, SALESREP_ID, BILL_BPARTNER_ID,
BILL_LOCATION_ID, BILL_USER_ID, ISDROPSHIP, C_BPARTNER_ID, C_BPARTNER_LOCATION_ID,
AD_USER_ID, POREFERENCE, C_CURRENCY_ID, ISSOTRX, C_CAMPAIGN_ID,
C_PROJECT_ID, C_ACTIVITY_ID, C_PROJECTPHASE_ID, C_PROJECTTASK_ID, C_ORDERLINE_ID,
DATEORDERED, DATEPROMISED, M_PRODUCT_ID, M_WAREHOUSE_ID, M_ATTRIBUTESETINSTANCE_ID,
PRODUCTATTRIBUTE, M_ATTRIBUTESET_ID, M_LOT_ID, GUARANTEEDATE, LOT,
SERNO, C_UOM_ID, QTYENTERED, QTYORDERED, QTYRESERVED,
QTYDELIVERED, QTYINVOICED, PRICEACTUAL, PRICEENTERED, QTYTODELIVER,
QTYTOINVOICE, NETAMTTOINVOICE, QTYLOSTSALES, AMTLOSTSALES, DISCOUNT,
MARGIN, MARGINAMT)
AS
SELECT l.AD_Client_ID, l.AD_Org_ID,
l.IsActive, l.Created, l.CreatedBy, l.Updated, l.UpdatedBy,
o.C_Order_ID, o.DocStatus, o.DocAction, o.C_DocType_ID, o.IsApproved, o.IsCreditApproved,
o.SalesRep_ID,
o.Bill_BPartner_ID, o.Bill_Location_ID, o.Bill_User_ID, o.IsDropShip,
l.C_BPartner_ID, l.C_BPartner_Location_ID, o.AD_User_ID,
o.POReference, o.C_Currency_ID, o.IsSOTrx,
l.C_Campaign_ID, l.C_Project_ID, l.C_Activity_ID, l.C_ProjectPhase_ID, l.C_ProjectTask_ID,
l.C_OrderLine_ID, l.DateOrdered, l.DatePromised, l.M_Product_ID, l.M_Warehouse_ID,
l.M_AttributeSetInstance_ID, productAttribute(l.M_AttributeSetInstance_ID) AS ProductAttribute,
pasi.M_AttributeSet_ID, pasi.M_Lot_ID, pasi.GuaranteeDate, pasi.Lot, pasi.SerNo,
l.C_UOM_ID, l.QtyEntered, l.QtyOrdered, l.QtyReserved, l.QtyDelivered, l.QtyInvoiced,
l.PriceActual, l.PriceEntered,
l.QtyOrdered-l.QtyDelivered AS QtyToDeliver,
l.QtyOrdered-l.QtyInvoiced AS QtyToInvoice,
(l.QtyOrdered-l.QtyInvoiced)*l.PriceActual AS NetAmtToInvoice,
l.QtyLostSales, l.QtyLostSales*l.PriceActual AS AmtLostSales,
CASE WHEN PriceList=0 THEN 0 ELSE
ROUND((PriceList-PriceActual)/PriceList*100,2) END AS Discount,
CASE WHEN PriceLimit=0 THEN 0 ELSE
ROUND((PriceActual-PriceLimit)/PriceLimit*100,2) END AS Margin,
CASE WHEN PriceLimit=0 THEN 0 ELSE
(PriceActual-PriceLimit)*QtyDelivered END AS MarginAmt
FROM C_Order o
INNER JOIN C_OrderLine l ON (o.C_Order_ID=l.C_Order_ID)
LEFT OUTER JOIN M_AttributeSetInstance pasi ON (l.M_AttributeSetInstance_ID=pasi.M_AttributeSetInstance_ID);
DROP VIEW rv_orderdetail;
CREATE OR REPLACE VIEW rv_orderdetail AS
SELECT l.ad_client_id, l.ad_org_id, l.isactive, l.created, l.createdby, l.updated, l.updatedby, o.c_order_id, o.docstatus, o.docaction, o.c_doctype_id, o.isapproved, o.iscreditapproved, o.salesrep_id, o.bill_bpartner_id, o.bill_location_id, o.bill_user_id, o.isdropship, l.c_bpartner_id, l.c_bpartner_location_id, o.ad_user_id, o.poreference, o.c_currency_id, o.issotrx, l.c_campaign_id, l.c_project_id, l.c_activity_id, l.c_projectphase_id, l.c_projecttask_id, l.c_orderline_id, l.dateordered, l.datepromised, l.m_product_id, l.m_warehouse_id, l.m_attributesetinstance_id, productattribute(l.m_attributesetinstance_id) AS productattribute, pasi.m_attributeset_id, pasi.m_lot_id, pasi.guaranteedate, pasi.lot, pasi.serno, l.c_uom_id, l.qtyentered, l.qtyordered, l.qtyreserved, l.qtydelivered, l.qtyinvoiced, l.priceactual, l.priceentered, l.qtyordered - l.qtydelivered AS qtytodeliver, l.qtyordered - l.qtyinvoiced AS qtytoinvoice, (l.qtyordered - l.qtyinvoiced) * l.priceactual AS netamttoinvoice, l.qtylostsales, 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.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_orgtrx_id AS c_order_ad_orgtrx_id, o.amountrefunded, o.amounttendered, o.c_activity_id AS c_order_c_activity_id, o.c_bpartner_id AS c_order_c_bpartner_id, o.c_bpartner_location_id AS c_order_c_bpartner_location_i, o.c_campaign_id AS c_order_c_compaign_id, o.c_cashline_id, o.c_cashplanline_id, o.c_charge_id AS c_order_c_charge_id, o.c_conversiontype_id, o.c_doctypetarget_id, o.chargeamt, o.copyfrom, o.c_payment_id, o.c_paymentterm_id, o.c_pos_id, o.c_project_id AS c_order_c_project_id, o.created AS c_order_created, o.createdby AS c_order_createdby, o.dateacct, o.dateordered AS c_order_dateordered, o.dateprinted, o.datepromised AS c_order_datepromised, o.deliveryrule, o.deliveryviarule, o.description AS c_order_description, o.documentno, o.dropship_bpartner_id, o.dropship_location_id, o.dropship_user_id, o.freightamt AS c_order_freightamt, o.freightcostrule, o.grandtotal, o.invoicerule, o.isactive AS c_order_isactive, o.isdelivered, o.isdiscountprinted, o.isinvoiced, o.ispayschedulevalid, o.isprinted, o.isselected, o.isselfservice, o.istaxincluded, o.istransferred, o.link_order_id, o.m_freightcategory_id, o.m_pricelist_id, o.m_shipper_id AS c_order_m_shipper_id, o.m_warehouse_id AS c_order_m_warehouse_id, o.ordertype, o.pay_bpartner_id, o.pay_location_id, o.paymentrule, o.posted, o.priorityrule, o.processed AS c_order_processed, o.processedon, o.promotioncode, o.ref_order_id, o.sendemail, o.totallines, o.updated AS c_order_updated, o.updatedby AS c_order_updatedby, o.user1_id AS c_order_user1_id, o.user2_id AS c_order_user2_id, o.volume, o.weight, l.ad_orgtrx_id AS c_orderline_ad_orgtrx_id, l.c_charge_id AS c_orderline_c_charge_id, l.c_currency_id AS c_orderline_c_currency_id, l.c_tax_id, l.datedelivered, l.dateinvoiced, l.description AS c_orderline_description, l.discount AS c_orderline_discount, l.freightamt AS c_orderline_freightamt, l.isdescription, l.line, l.linenetamt, l.link_orderline_id, l.m_promotion_id, l.m_shipper_id AS c_orderline_m_shipper_id, l.pricecost, l.pricelimit, l.pricelist, l.processed AS c_orderline_processed, l.ref_orderline_id, l.rramt, l.rrstartdate, l.s_resourceassignment_id, l.user1_id AS c_orderline_user1_id, l.user2_id AS c_orderline_user2_id, pasi.ad_org_id AS m_asi_ad_org_id, pasi.created AS m_asi_created, pasi.createdby AS m_asi_createdby, pasi.description AS m_asi_description, pasi.isactive AS m_asi_isactive, pasi.updated AS m_asi_updated, pasi.updatedby AS m_asi_updatedby
FROM c_order o
JOIN c_orderline l ON o.c_order_id = l.c_order_id
LEFT JOIN m_attributesetinstance pasi ON l.m_attributesetinstance_id = pasi.m_attributesetinstance_id;

View File

@ -1,45 +1,30 @@
CREATE OR REPLACE VIEW RV_PAYMENT
(C_PAYMENT_ID, AD_CLIENT_ID, AD_ORG_ID, ISACTIVE, CREATED,
CREATEDBY, UPDATED, UPDATEDBY, DOCUMENTNO, DATETRX,
ISRECEIPT, C_DOCTYPE_ID, TRXTYPE, C_BANKACCOUNT_ID, C_BPARTNER_ID,
C_INVOICE_ID, C_BP_BANKACCOUNT_ID, C_PAYMENTBATCH_ID, TENDERTYPE, CREDITCARDTYPE,
CREDITCARDNUMBER, CREDITCARDVV, CREDITCARDEXPMM, CREDITCARDEXPYY, MICR,
ROUTINGNO, ACCOUNTNO, CHECKNO, A_NAME, A_STREET,
A_CITY, A_STATE, A_ZIP, A_IDENT_DL, A_IDENT_SSN,
A_EMAIL, VOICEAUTHCODE, ORIG_TRXID, PONUM, C_CURRENCY_ID,
C_CONVERSIONTYPE_ID, PAYAMT, DISCOUNTAMT, WRITEOFFAMT, TAXAMT,
OVERUNDERAMT, MULTIPLIERAP, ALLOCATEDAMT, AVAILABLEAMT, ISOVERUNDERPAYMENT,
ISAPPROVED, R_PNREF, R_RESULT, R_RESPMSG, R_AUTHCODE,
R_AVSADDR, R_AVSZIP, R_INFO, PROCESSING, OPROCESSING,
DOCSTATUS, DOCACTION, ISPREPAYMENT, C_CHARGE_ID, ISRECONCILED,
ISALLOCATED, ISONLINE, PROCESSED, POSTED, C_CAMPAIGN_ID,
C_PROJECT_ID, C_ACTIVITY_ID)
AS
SELECT C_Payment_ID, AD_Client_ID, AD_Org_ID, IsActive, Created, CreatedBy, Updated, UpdatedBy,
DocumentNo, DateTrx, IsReceipt, C_DocType_ID, TrxType,
C_BankAccount_ID, C_BPartner_ID, C_Invoice_ID, C_BP_BankAccount_ID, C_PaymentBatch_ID,
TenderType, CreditCardType, CreditCardNumber, CreditCardVV, CreditCardExpMM, CreditCardExpYY,
Micr, RoutingNo, AccountNo, CheckNo,
A_Name, A_Street, A_City, A_State, A_Zip, A_Ident_DL, A_Ident_SSN, A_EMail,
VoiceAuthCode, Orig_TrxID, PONum,
C_Currency_ID, C_ConversionType_ID,
CASE IsReceipt WHEN 'Y' THEN PayAmt ELSE PayAmt*-1 END AS PayAmt,
CASE IsReceipt WHEN 'Y' THEN DiscountAmt ELSE DiscountAmt*-1 END AS DiscountAmt,
CASE IsReceipt WHEN 'Y' THEN WriteOffAmt ELSE WriteOffAmt*-1 END AS WriteOffAmt,
CASE IsReceipt WHEN 'Y' THEN TaxAmt ELSE TaxAmt*-1 END AS TaxAmt,
CASE IsReceipt WHEN 'Y' THEN OverUnderAmt ELSE OverUnderAmt*-1 END AS OverUnderAmt,
CASE IsReceipt WHEN 'Y' THEN 1 ELSE -1 END AS MultiplierAP,
paymentAllocated(C_Payment_ID, C_Currency_ID) AS AllocatedAmt,
paymentAvailable(C_Payment_ID) AS AvailableAmt,
IsOverUnderPayment, IsApproved,
R_PnRef, R_Result, R_RespMsg, R_AuthCode, R_AvsAddr, R_AvsZip, R_Info,
Processing, OProcessing, DocStatus, DocAction,
IsPrepayment, C_Charge_ID,
IsReconciled, IsAllocated, IsOnline, Processed, Posted,
C_Campaign_ID, C_Project_ID, C_Activity_ID
FROM C_Payment;
--COMMENT ON TABLE RV_PAYMENT IS 'Payment Information corrected for AP/AR';
DROP VIEW rv_payment;
CREATE OR REPLACE VIEW rv_payment AS
SELECT c_payment.c_payment_id, c_payment.ad_client_id, c_payment.ad_org_id, c_payment.isactive, c_payment.created, c_payment.createdby, c_payment.updated, c_payment.updatedby, c_payment.documentno, c_payment.datetrx, c_payment.isreceipt, c_payment.c_doctype_id, c_payment.trxtype, c_payment.c_bankaccount_id, c_payment.c_bpartner_id, c_payment.c_invoice_id, c_payment.c_bp_bankaccount_id, c_payment.c_paymentbatch_id, c_payment.tendertype, c_payment.creditcardtype, c_payment.creditcardnumber, c_payment.creditcardvv, c_payment.creditcardexpmm, c_payment.creditcardexpyy, c_payment.micr, c_payment.routingno, c_payment.accountno, c_payment.checkno, c_payment.a_name, c_payment.a_street, c_payment.a_city, c_payment.a_state, c_payment.a_zip, c_payment.a_ident_dl, c_payment.a_ident_ssn, c_payment.a_email, c_payment.voiceauthcode, c_payment.orig_trxid, c_payment.ponum, c_payment.c_currency_id, c_payment.c_conversiontype_id,
CASE c_payment.isreceipt
WHEN 'Y' THEN c_payment.payamt
ELSE c_payment.payamt * (-1)
END AS payamt,
CASE c_payment.isreceipt
WHEN 'Y' THEN c_payment.discountamt
ELSE c_payment.discountamt * (-1)
END AS discountamt,
CASE c_payment.isreceipt
WHEN 'Y' THEN c_payment.writeoffamt
ELSE c_payment.writeoffamt * (-1)
END AS writeoffamt,
CASE c_payment.isreceipt
WHEN 'Y' THEN c_payment.taxamt
ELSE c_payment.taxamt * (-1)
END AS taxamt,
CASE c_payment.isreceipt
WHEN 'Y' THEN c_payment.overunderamt
ELSE c_payment.overunderamt * (-1)
END AS overunderamt,
CASE c_payment.isreceipt
WHEN 'Y' THEN 1
ELSE (-1)
END AS multiplierap, paymentallocated(c_payment.c_payment_id, c_payment.c_currency_id) AS allocatedamt, paymentavailable(c_payment.c_payment_id) AS availableamt, c_payment.isoverunderpayment, c_payment.isapproved, c_payment.r_pnref, c_payment.r_result, c_payment.r_respmsg, c_payment.r_authcode, c_payment.r_avsaddr, c_payment.r_avszip, c_payment.r_info, c_payment.processing, c_payment.oprocessing, c_payment.docstatus, c_payment.docaction, c_payment.isprepayment, c_payment.c_charge_id, c_payment.isreconciled, c_payment.isallocated, c_payment.isonline, c_payment.processed, c_payment.posted, c_payment.c_campaign_id, c_payment.c_project_id, c_payment.c_activity_id, c_payment.a_country, c_payment.ad_orgtrx_id, c_payment.chargeamt, c_payment.c_order_id, c_payment.dateacct, c_payment.description, c_payment.isdelayedcapture, c_payment.isselfservice, c_payment.processedon, c_payment.r_authcode_dc, c_payment.r_cvv2match, c_payment.ref_payment_id, c_payment.reversal_id, c_payment.r_pnref_dc, c_payment.swipe, c_payment.user1_id, c_payment.user2_id
FROM c_payment;

View File

@ -1,35 +1,11 @@
CREATE OR REPLACE VIEW RV_STORAGE
(AD_CLIENT_ID, AD_ORG_ID, M_PRODUCT_ID, VALUE, NAME,
DESCRIPTION, UPC, SKU, C_UOM_ID, M_PRODUCT_CATEGORY_ID,
CLASSIFICATION, WEIGHT, VOLUME, VERSIONNO, GUARANTEEDAYS,
GUARANTEEDAYSMIN, M_LOCATOR_ID, M_WAREHOUSE_ID, X, Y,
Z, QTYONHAND, QTYRESERVED, QTYAVAILABLE, QTYORDERED,
DATELASTINVENTORY, M_ATTRIBUTESETINSTANCE_ID, M_ATTRIBUTESET_ID, SERNO, LOT,
M_LOT_ID, GUARANTEEDATE, SHELFLIFEDAYS, GOODFORDAYS, SHELFLIFEREMAININGPCT)
AS
SELECT s.AD_Client_ID, s.AD_Org_ID,
-- Product
s.M_Product_ID, p.Value,p.Name, p.Description, p.UPC, p.SKU,
p.C_UOM_ID, p.M_Product_Category_ID, p.Classification, p.Weight, p.Volume, p.VersionNo,
p.GuaranteeDays, p.GuaranteeDaysMin,
-- Locator
s.M_Locator_ID, l.M_Warehouse_ID, l.X, l.Y, l.Z,
-- Storage
s.QtyOnHand, s.QtyReserved, s.QtyOnHand-s.QtyReserved AS QtyAvailable,
s.QtyOrdered, s.DateLastInventory,
-- Instance
s.M_AttributeSetInstance_ID, asi.M_AttributeSet_ID, asi.SerNo, asi.Lot, asi.M_Lot_ID,
asi.GuaranteeDate, -- see PAttributeInstance.java
daysBetween(asi.GuaranteeDate,getdate()) AS ShelfLifeDays,
daysBetween(asi.GuaranteeDate,getdate())-p.GuaranteeDaysMin AS GoodForDays,
CASE WHEN COALESCE(p.GuaranteeDays,0)>0
THEN ROUND((daysBetween(asi.GuaranteeDate,getdate())/p.GuaranteeDays)*100,0)
ELSE NULL
END AS ShelfLifeRemainingPct
FROM M_Storage s
INNER JOIN M_Locator l ON (s.M_Locator_ID=l.M_Locator_ID)
INNER JOIN M_Product p ON (s.M_Product_ID=p.M_Product_ID)
LEFT OUTER JOIN M_AttributeSetInstance asi ON (s.M_AttributeSetInstance_ID=asi.M_AttributeSetInstance_ID);
CREATE OR REPLACE VIEW rv_storage AS
SELECT s.ad_client_id, s.ad_org_id, s.m_product_id, p.value, p.name, p.description, p.upc, p.sku, p.c_uom_id, p.m_product_category_id, p.classification, p.weight, p.volume, p.versionno, p.guaranteedays, p.guaranteedaysmin, s.m_locator_id, l.m_warehouse_id, l.x, l.y, l.z, s.qtyonhand, s.qtyreserved, s.qtyonhand - s.qtyreserved AS qtyavailable, s.qtyordered, s.datelastinventory, s.m_attributesetinstance_id, asi.m_attributeset_id, asi.serno, asi.lot, asi.m_lot_id, asi.guaranteedate, daysbetween(asi.guaranteedate, getdate()) AS shelflifedays, daysbetween(asi.guaranteedate, getdate()) - p.guaranteedaysmin AS goodfordays,
CASE
WHEN COALESCE(p.guaranteedays, 0) > 0 THEN round(daysbetween(asi.guaranteedate, getdate()) / p.guaranteedays * 100, 0)
ELSE NULL
END AS shelfliferemainingpct, s.isactive AS m_storage_isactive, s.updated AS m_storage_updated, s.updatedby AS m_storage_updatedby, l.ad_org_id AS m_locator_ad_org_id, l.isactive AS m_locator_isactive, l.isdefault, l.priorityno, l.value AS m_locator_value, p.ad_org_id AS m_product_ad_org_id, p.copyfrom AS m_product_copyfrom, p.created AS m_product_created, p.createdby AS m_product_createdby, p.c_revenuerecognition_id, p.c_subscriptiontype_id, p.c_taxcategory_id, p.descriptionurl, p.discontinued AS m_product_discontinued, p.discontinuedat AS m_product_discontinuedat, p.documentnote, p.group1, p.group2, p.help, p.imageurl, p.isactive AS m_product_isactive, p.isbom, p.isdropship, p.isexcludeautodelivery, p.isinvoiceprintdetails, p.ispicklistprintdetails, p.ispurchased, p.isselfservice, p.issold, p.isstocked, p.issummary AS m_product_issummary, p.isverified, p.iswebstorefeatured, p.lowlevel, p.m_attributeset_id AS m_product_m_attributeset_id, p.m_attributesetinstance_id AS m_product_m_asi_id, p.m_freightcategory_id, p.m_locator_id AS m_product_m_locator_id, p.processing AS m_product_processing, p.producttype, p.r_mailtext_id, p.salesrep_id AS m_product_salesrep_id, p.s_expensetype_id, p.shelfdepth, p.shelfheight, p.shelfwidth, p.s_resource_id, p.unitsperpack, p.unitsperpallet, p.updated AS m_product_updated, p.updatedby AS m_product_updatedby, asi.ad_org_id AS m_asi_ad_org_id, asi.created AS m_asi_created, asi.createdby AS m_asi_createdby, asi.description AS m_asi_description, asi.isactive AS m_asi_isactive, asi.updated AS m_asi_updated, asi.updatedby AS m_asi_updatedby
FROM m_storage s
JOIN m_locator l ON s.m_locator_id = l.m_locator_id
JOIN m_product p ON s.m_product_id = p.m_product_id
LEFT JOIN m_attributesetinstance asi ON s.m_attributesetinstance_id = asi.m_attributesetinstance_id;

File diff suppressed because one or more lines are too long

View File

@ -1,45 +1,8 @@
CREATE OR REPLACE VIEW T_INVOICEGL_V
(AD_CLIENT_ID, AD_ORG_ID, ISACTIVE, CREATED, CREATEDBY,
UPDATED, UPDATEDBY, C_INVOICE_ID, ISSOTRX, DOCUMENTNO,
DOCSTATUS, C_DOCTYPE_ID, C_ORDER_ID, DESCRIPTION, SALESREP_ID,
DATEINVOICED, DATEACCT, C_PAYMENTTERM_ID, C_BPARTNER_ID, C_BPARTNER_LOCATION_ID,
AD_USER_ID, ISSELFSERVICE, C_CURRENCY_ID, C_CONVERSIONTYPE_ID, GRANDTOTAL,
ISTAXINCLUDED, C_CAMPAIGN_ID, C_PROJECT_ID, C_ACTIVITY_ID, AD_ORGTRX_ID,
USER1_ID, USER2_ID, C_LOCFROM_ID, C_LOCTO_ID, C_SALESREGION_ID,
FACT_ACCT_ID, C_ACCTSCHEMA_ID, ACCOUNT_ID, C_PERIOD_ID, GL_CATEGORY_ID,
GL_BUDGET_ID, C_TAX_ID, M_LOCATOR_ID, POSTINGTYPE, AMTSOURCEDR,
AMTSOURCECR, AMTACCTDR, AMTACCTCR, C_UOM_ID, QTY,
AD_PINSTANCE_ID, APAR, OPENAMT, PERCENT, AMTREVALDR,
AMTREVALCR, DATEREVAL, C_CONVERSIONTYPEREVAL_ID, AMTSOURCEBALANCE, AMTACCTBALANCE,
C_DOCTYPEREVAL_ID, AMTREVALDRDIFF, AMTREVALCRDIFF, ISALLCURRENCIES, AMTACCTOPENDR,
AMTACCTOPENCR, AMTACCTOPENBALANCE)
AS
SELECT i.AD_Client_ID, i.AD_Org_ID, i.IsActive, i.Created,i.CreatedBy, i.Updated,i.UpdatedBy,
i.C_Invoice_ID, i.IsSOTrx, i.DocumentNo, i.DocStatus, i.C_DocType_ID, i.C_Order_ID,
i.Description, i.SalesRep_ID, i.DateInvoiced, i.DateAcct, i.C_PaymentTerm_ID,
i.C_BPartner_ID, i.C_BPartner_Location_ID, i.AD_User_ID, i.IsSelfService,
i.C_Currency_ID, i.C_ConversionType_ID, i.GrandTotal, i.IsTaxIncluded,
-- References
i.C_Campaign_ID, i.C_Project_ID, i.C_Activity_ID,
i.AD_OrgTrx_ID, i.User1_ID, i.User2_ID,
fa.C_LocFrom_ID, fa.C_LocTo_ID, fa.C_SalesRegion_ID,
-- Accounting
fa.Fact_Acct_ID, fa.C_AcctSchema_ID, fa.Account_ID, fa.C_Period_ID, fa.GL_Category_ID, fa.GL_Budget_ID,
fa.C_Tax_ID, fa.M_Locator_ID,
fa.PostingType, fa.AmtSourceDr, fa.AmtSourceCr,
fa.AmtAcctDr, fa.AmtAcctCr,
fa.C_UOM_ID, fa.Qty,
-- Gain/Loss
gl.AD_PInstance_ID, gl.APAR, gl.OpenAmt, gl.Percent,
gl.AmtRevalDr, gl.AmtRevalCr, gl.DateReval, gl.C_ConversionTypeReval_ID,
gl.AmtSourceBalance, gl.AmtAcctBalance,
gl.C_DocTypeReval_ID,
gl.AmtRevalDrDiff, gl.AmtRevalCrDiff, gl.IsAllCurrencies,
(fa.AmtAcctDr*gl.Percent/100) AS AmtAcctOpenDr, (fa.AmtAcctCr*gl.Percent/100) AS AmtAcctOpenCr,
((fa.AmtAcctDr-fa.AmtAcctCr)*gl.Percent/100) AS AmtAcctOpenBalance
FROM T_InvoiceGL gl
INNER JOIN C_Invoice i ON (gl.C_Invoice_ID=i.C_Invoice_ID)
INNER JOIN Fact_Acct fa ON (gl.Fact_Acct_ID=fa.Fact_Acct_ID);
DROP VIEW t_invoicegl_v;
CREATE OR REPLACE VIEW t_invoicegl_v AS
SELECT i.ad_client_id, i.ad_org_id, i.isactive, i.created, i.createdby, i.updated, i.updatedby, i.c_invoice_id, i.issotrx, i.documentno, i.docstatus, i.c_doctype_id, i.c_order_id, i.description, i.salesrep_id, i.dateinvoiced, i.dateacct, i.c_paymentterm_id, i.c_bpartner_id, i.c_bpartner_location_id, i.ad_user_id, i.isselfservice, i.c_currency_id, i.c_conversiontype_id, i.grandtotal, i.istaxincluded, i.c_campaign_id, i.c_project_id, i.c_activity_id, i.ad_orgtrx_id, i.user1_id, i.user2_id, fa.c_locfrom_id, fa.c_locto_id, fa.c_salesregion_id, fa.fact_acct_id, fa.c_acctschema_id, fa.account_id, fa.c_period_id, fa.gl_category_id, fa.gl_budget_id, fa.c_tax_id, fa.m_locator_id, fa.postingtype, fa.amtsourcedr, fa.amtsourcecr, fa.amtacctdr, fa.amtacctcr, fa.c_uom_id, fa.qty, gl.ad_pinstance_id, gl.apar, gl.openamt, gl.percent, gl.amtrevaldr, gl.amtrevalcr, gl.datereval, gl.c_conversiontypereval_id, gl.amtsourcebalance, gl.amtacctbalance, gl.c_doctypereval_id, gl.amtrevaldrdiff, gl.amtrevalcrdiff, gl.isallcurrencies, fa.amtacctdr * gl.percent / 100 AS amtacctopendr, fa.amtacctcr * gl.percent / 100 AS amtacctopencr, (fa.amtacctdr - fa.amtacctcr) * gl.percent / 100 AS amtacctopenbalance, gl.ad_org_id AS t_invoicegl_ad_org_id, gl.c_invoice_id AS t_invoicegl_c_invoice_id, gl.created AS t_invoicegl_created, gl.createdby AS t_invoicegl_createdby, gl.grandtotal AS t_invoicegl_grandtotal, gl.isactive AS t_invoicegl_isactive, gl.updated AS t_invoicegl_updated, gl.updatedby AS t_invoicegl_updatedby, i.c_charge_id AS c_invoice_c_charge_id, i.c_doctypetarget_id, i.c_dunninglevel_id, i.chargeamt, i.c_payment_id, i.dateordered, i.dateprinted, i.docaction, i.dunninggrace, i.generateto, i.invoicecollectiontype, i.isapproved, i.isdiscountprinted, i.isindispute, i.ispaid, i.ispayschedulevalid, i.isprinted, i.istransferred, i.m_pricelist_id, i.m_rma_id, i.paymentrule, i.poreference, i.posted, i.processedon, i.processing, i.ref_invoice_id, i.reversal_id, i.sendemail, i.totallines, fa.a_asset_id, fa.ad_org_id AS fact_acct_ad_org_id, fa.ad_orgtrx_id AS fact_acct_ad_orgtrx_id, fa.ad_table_id AS fact_acct_ad_table_id, fa.c_activity_id AS fact_acct_c_activity_id, fa.c_bpartner_id AS fact_acct_c_bpartner_id, fa.c_campaign_id AS fact_acct_c_campaign_id, fa.c_currency_id AS fact_acct_c_currency_id, fa.c_subacct_id, fa.dateacct AS fact_acct_dateacct, fa.datetrx, fa.description AS fact_acct_description, fa.isactive AS fact_acct_isactive, fa.line_id, fa.m_product_id AS fact_acct_m_product_id, fa.record_id, fa.updated AS fact_acct_updated, fa.updatedby AS fact_acct_updatedby, fa.user1_id AS fact_acct_user1_id, fa.user2_id AS fact_acct_user2_id, fa.userelement1_id, fa.userelement2_id
FROM t_invoicegl gl
JOIN c_invoice i ON gl.c_invoice_id = i.c_invoice_id
JOIN fact_acct fa ON gl.fact_acct_id = fa.fact_acct_id;

View File

@ -1,45 +1,8 @@
CREATE OR REPLACE VIEW T_INVOICEGL_VT
(AD_CLIENT_ID, AD_ORG_ID, ISACTIVE, CREATED, CREATEDBY,
UPDATED, UPDATEDBY, C_INVOICE_ID, ISSOTRX, DOCUMENTNO,
DOCSTATUS, C_DOCTYPE_ID, C_ORDER_ID, DESCRIPTION, SALESREP_ID,
DATEINVOICED, DATEACCT, C_PAYMENTTERM_ID, C_BPARTNER_ID, C_BPARTNER_LOCATION_ID,
AD_USER_ID, ISSELFSERVICE, C_CURRENCY_ID, C_CONVERSIONTYPE_ID, GRANDTOTAL,
ISTAXINCLUDED, C_CAMPAIGN_ID, C_PROJECT_ID, C_ACTIVITY_ID, AD_ORGTRX_ID,
USER1_ID, USER2_ID, C_LOCFROM_ID, C_LOCTO_ID, C_SALESREGION_ID,
FACT_ACCT_ID, C_ACCTSCHEMA_ID, ACCOUNT_ID, C_PERIOD_ID, GL_CATEGORY_ID,
GL_BUDGET_ID, C_TAX_ID, M_LOCATOR_ID, POSTINGTYPE, AMTSOURCEDR,
AMTSOURCECR, AMTACCTDR, AMTACCTCR, C_UOM_ID, QTY,
AD_PINSTANCE_ID, APAR, OPENAMT, PERCENT, AMTREVALDR,
AMTREVALCR, DATEREVAL, C_CONVERSIONTYPEREVAL_ID, AMTSOURCEBALANCE, AMTACCTBALANCE,
C_DOCTYPEREVAL_ID, AMTREVALDRDIFF, AMTREVALCRDIFF, ISALLCURRENCIES, AMTACCTOPENDR,
AMTACCTOPENCR, AMTACCTOPENBALANCE)
AS
SELECT i.AD_Client_ID, i.AD_Org_ID, i.IsActive, i.Created,i.CreatedBy, i.Updated,i.UpdatedBy,
i.C_Invoice_ID, i.IsSOTrx, i.DocumentNo, i.DocStatus, i.C_DocType_ID, i.C_Order_ID,
i.Description, i.SalesRep_ID, i.DateInvoiced, i.DateAcct, i.C_PaymentTerm_ID,
i.C_BPartner_ID, i.C_BPartner_Location_ID, i.AD_User_ID, i.IsSelfService,
i.C_Currency_ID, i.C_ConversionType_ID, i.GrandTotal, i.IsTaxIncluded,
-- References
i.C_Campaign_ID, i.C_Project_ID, i.C_Activity_ID,
i.AD_OrgTrx_ID, i.User1_ID, i.User2_ID,
fa.C_LocFrom_ID, fa.C_LocTo_ID, fa.C_SalesRegion_ID,
-- Accounting
fa.Fact_Acct_ID, fa.C_AcctSchema_ID, fa.Account_ID, fa.C_Period_ID, fa.GL_Category_ID, fa.GL_Budget_ID,
fa.C_Tax_ID, fa.M_Locator_ID,
fa.PostingType, fa.AmtSourceDr, fa.AmtSourceCr,
fa.AmtAcctDr, fa.AmtAcctCr,
fa.C_UOM_ID, fa.Qty,
-- Gain/Loss
gl.AD_PInstance_ID, gl.APAR, gl.OpenAmt, gl.Percent,
gl.AmtRevalDr, gl.AmtRevalCr, gl.DateReval, gl.C_ConversionTypeReval_ID,
gl.AmtSourceBalance, gl.AmtAcctBalance,
gl.C_DocTypeReval_ID,
gl.AmtRevalDrDiff, gl.AmtRevalCrDiff, gl.IsAllCurrencies,
(fa.AmtAcctDr*gl.Percent/100) AS AmtAcctOpenDr, (fa.AmtAcctCr*gl.Percent/100) AS AmtAcctOpenCr,
((fa.AmtAcctDr-fa.AmtAcctCr)*gl.Percent/100) AS AmtAcctOpenBalance
FROM T_InvoiceGL gl
INNER JOIN C_Invoice i ON (gl.C_Invoice_ID=i.C_Invoice_ID)
INNER JOIN Fact_Acct fa ON (gl.Fact_Acct_ID=fa.Fact_Acct_ID);
DROP VIEW t_invoicegl_vt;
CREATE OR REPLACE VIEW t_invoicegl_vt AS
SELECT i.ad_client_id, i.ad_org_id, i.isactive, i.created, i.createdby, i.updated, i.updatedby, i.c_invoice_id, i.issotrx, i.documentno, i.docstatus, i.c_doctype_id, i.c_order_id, i.description, i.salesrep_id, i.dateinvoiced, i.dateacct, i.c_paymentterm_id, i.c_bpartner_id, i.c_bpartner_location_id, i.ad_user_id, i.isselfservice, i.c_currency_id, i.c_conversiontype_id, i.grandtotal, i.istaxincluded, i.c_campaign_id, i.c_project_id, i.c_activity_id, i.ad_orgtrx_id, i.user1_id, i.user2_id, fa.c_locfrom_id, fa.c_locto_id, fa.c_salesregion_id, fa.fact_acct_id, fa.c_acctschema_id, fa.account_id, fa.c_period_id, fa.gl_category_id, fa.gl_budget_id, fa.c_tax_id, fa.m_locator_id, fa.postingtype, fa.amtsourcedr, fa.amtsourcecr, fa.amtacctdr, fa.amtacctcr, fa.c_uom_id, fa.qty, gl.ad_pinstance_id, gl.apar, gl.openamt, gl.percent, gl.amtrevaldr, gl.amtrevalcr, gl.datereval, gl.c_conversiontypereval_id, gl.amtsourcebalance, gl.amtacctbalance, gl.c_doctypereval_id, gl.amtrevaldrdiff, gl.amtrevalcrdiff, gl.isallcurrencies, fa.amtacctdr * gl.percent / 100 AS amtacctopendr, fa.amtacctcr * gl.percent / 100 AS amtacctopencr, (fa.amtacctdr - fa.amtacctcr) * gl.percent / 100 AS amtacctopenbalance, gl.ad_org_id AS t_invoicegl_ad_org_id, gl.c_invoice_id AS t_invoicegl_c_invoice_id, gl.created AS t_invoicegl_created, gl.createdby AS t_invoicegl_createdby, gl.grandtotal AS t_invoicegl_grandtotal, gl.isactive AS t_invoicegl_isactive, gl.updated AS t_invoicegl_updated, gl.updatedby AS t_invoicegl_updatedby, i.c_charge_id AS c_invoice_c_charge_id, i.c_doctypetarget_id, i.c_dunninglevel_id, i.chargeamt, i.c_payment_id, i.dateordered, i.dateprinted, i.docaction, i.dunninggrace, i.generateto, i.invoicecollectiontype, i.isapproved, i.isdiscountprinted, i.isindispute, i.ispaid, i.ispayschedulevalid, i.isprinted, i.istransferred, i.m_pricelist_id, i.m_rma_id, i.paymentrule, i.poreference, i.posted, i.processedon, i.processing, i.ref_invoice_id, i.reversal_id, i.sendemail, i.totallines, fa.a_asset_id, fa.ad_org_id AS fact_acct_ad_org_id, fa.ad_orgtrx_id AS fact_acct_ad_orgtrx_id, fa.ad_table_id AS fact_acct_ad_table_id, fa.c_activity_id AS fact_acct_c_activity_id, fa.c_bpartner_id AS fact_acct_c_bpartner_id, fa.c_campaign_id AS fact_acct_c_campaign_id, fa.c_currency_id AS fact_acct_c_currency_id, fa.c_subacct_id, fa.dateacct AS fact_acct_dateacct, fa.datetrx, fa.description AS fact_acct_description, fa.isactive AS fact_acct_isactive, fa.line_id, fa.m_product_id AS fact_acct_m_product_id, fa.record_id, fa.updated AS fact_acct_updated, fa.updatedby AS fact_acct_updatedby, fa.user1_id AS fact_acct_user1_id, fa.user2_id AS fact_acct_user2_id, fa.userelement1_id, fa.userelement2_id
FROM t_invoicegl gl
JOIN c_invoice i ON gl.c_invoice_id = i.c_invoice_id
JOIN fact_acct fa ON gl.fact_acct_id = fa.fact_acct_id;

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff