Oracle throwing errors on migration script 201303191127_TICKET-1001025.sql / formatted SQL in all views
oracle error -> Input truncated to 7499 characters oracle error -> SP2-0027: Input is too long (> 2499 characters) - line ignored
This commit is contained in:
parent
613a7e782e
commit
c93bff9a1f
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -1,13 +1,180 @@
|
|||
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;
|
||||
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
|
||||
;
|
||||
|
||||
|
|
|
@ -1,13 +1,184 @@
|
|||
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);
|
||||
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
|
@ -1,44 +1,158 @@
|
|||
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';
|
||||
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
|
@ -1,28 +1,101 @@
|
|||
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;
|
||||
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
|
@ -1,9 +1,88 @@
|
|||
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;
|
||||
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
|
||||
;
|
||||
|
||||
|
|
|
@ -1,8 +1,90 @@
|
|||
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';
|
||||
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'
|
||||
;
|
||||
|
||||
|
|
|
@ -1,15 +1,147 @@
|
|||
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';
|
||||
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'
|
||||
;
|
||||
|
||||
|
|
|
@ -1,15 +1,151 @@
|
|||
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';
|
||||
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
|
@ -1,50 +1,447 @@
|
|||
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;
|
||||
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
|
||||
;
|
||||
|
||||
|
||||
|
|
|
@ -1,54 +1,458 @@
|
|||
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;
|
||||
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
|
||||
;
|
||||
|
||||
|
|
|
@ -1,7 +1,47 @@
|
|||
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;
|
||||
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
|
||||
;
|
||||
|
||||
|
|
|
@ -1,11 +1,169 @@
|
|||
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;
|
||||
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
|
||||
;
|
||||
|
||||
|
|
|
@ -1,12 +1,82 @@
|
|||
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');
|
||||
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
|
@ -1,9 +1,105 @@
|
|||
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;
|
||||
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
|
||||
;
|
||||
|
||||
|
|
|
@ -1,9 +1,119 @@
|
|||
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;
|
||||
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
|
||||
;
|
||||
|
||||
|
|
|
@ -1,24 +1,192 @@
|
|||
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;
|
||||
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
|
||||
;
|
||||
|
||||
|
|
|
@ -1,27 +1,156 @@
|
|||
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;
|
||||
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
|
||||
;
|
||||
|
||||
|
|
|
@ -1,25 +1,161 @@
|
|||
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;
|
||||
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
|
||||
;
|
||||
|
||||
|
|
|
@ -1,12 +1,206 @@
|
|||
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;
|
||||
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
|
||||
;
|
||||
|
||||
|
|
|
@ -1,9 +1,138 @@
|
|||
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;
|
||||
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
|
||||
;
|
||||
|
||||
|
|
|
@ -1,9 +1,117 @@
|
|||
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';
|
||||
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'
|
||||
;
|
||||
|
||||
|
|
|
@ -1,13 +1,158 @@
|
|||
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';
|
||||
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'
|
||||
;
|
||||
|
||||
|
|
|
@ -1,20 +1,178 @@
|
|||
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;
|
||||
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
|
||||
;
|
||||
|
||||
|
|
|
@ -1,30 +1,114 @@
|
|||
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;
|
||||
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
|
||||
;
|
||||
|
||||
|
|
|
@ -1,11 +1,110 @@
|
|||
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;
|
||||
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
|
@ -1,8 +1,137 @@
|
|||
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;
|
||||
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
|
||||
;
|
||||
|
||||
|
|
|
@ -1,8 +1,137 @@
|
|||
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;
|
||||
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
|
@ -1,13 +1,178 @@
|
|||
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;
|
||||
|
||||
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
|
||||
;
|
||||
|
|
|
@ -1,13 +1,181 @@
|
|||
DROP VIEW c_dunning_line_vt;
|
||||
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);
|
||||
|
||||
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
|
@ -1,44 +1,131 @@
|
|||
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'
|
||||
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';
|
||||
|
||||
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
|
@ -1,28 +1,81 @@
|
|||
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;
|
||||
|
||||
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
|
@ -1,9 +1,86 @@
|
|||
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;
|
||||
|
||||
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
|
||||
;
|
||||
|
|
|
@ -1,8 +1,88 @@
|
|||
DROP VIEW c_payselection_remittance_vt;
|
||||
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';
|
||||
|
||||
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'
|
||||
;
|
||||
|
|
|
@ -1,15 +1,142 @@
|
|||
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';
|
||||
|
||||
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'
|
||||
;
|
||||
|
|
|
@ -1,15 +1,146 @@
|
|||
DROP VIEW c_project_details_vt;
|
||||
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';
|
||||
|
||||
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
|
@ -1,50 +1,416 @@
|
|||
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;
|
||||
|
||||
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
|
||||
;
|
||||
|
|
|
@ -1,55 +1,428 @@
|
|||
DROP VIEW m_inout_line_vt;
|
||||
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;
|
||||
|
||||
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
|
||||
;
|
||||
|
|
|
@ -1,7 +1,45 @@
|
|||
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;
|
||||
|
||||
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
|
||||
;
|
||||
|
|
|
@ -1,11 +1,163 @@
|
|||
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;
|
||||
|
||||
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
|
||||
;
|
||||
|
|
|
@ -1,12 +1,79 @@
|
|||
DROP VIEW rv_bpartneropen;
|
||||
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')
|
||||
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');
|
||||
|
||||
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
|
@ -1,9 +1,103 @@
|
|||
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;
|
||||
|
||||
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
|
||||
;
|
||||
|
|
|
@ -1,9 +1,117 @@
|
|||
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;
|
||||
|
||||
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
|
||||
;
|
||||
|
|
|
@ -1,24 +1,178 @@
|
|||
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;
|
||||
|
||||
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
|
||||
;
|
||||
|
|
|
@ -1,27 +1,141 @@
|
|||
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;
|
||||
|
||||
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
|
||||
;
|
||||
|
|
|
@ -1,25 +1,147 @@
|
|||
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;
|
||||
|
||||
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
|
||||
;
|
||||
|
|
|
@ -1,12 +1,201 @@
|
|||
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;
|
||||
|
||||
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
|
||||
;
|
||||
|
|
|
@ -1,9 +1,136 @@
|
|||
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;
|
||||
|
||||
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
|
||||
;
|
||||
|
|
|
@ -1,9 +1,115 @@
|
|||
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';
|
||||
|
||||
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'
|
||||
;
|
||||
|
|
|
@ -1,13 +1,153 @@
|
|||
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')
|
||||
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';
|
||||
|
||||
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'
|
||||
;
|
||||
|
|
|
@ -1,20 +1,167 @@
|
|||
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;
|
||||
|
||||
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
|
||||
;
|
||||
|
|
|
@ -1,30 +1,94 @@
|
|||
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;
|
||||
|
||||
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
|
||||
;
|
||||
|
|
|
@ -1,11 +1,106 @@
|
|||
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;
|
||||
|
||||
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
|
@ -1,8 +1,135 @@
|
|||
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;
|
||||
|
||||
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
|
||||
;
|
||||
|
|
|
@ -1,8 +1,135 @@
|
|||
DROP VIEW t_invoicegl_vt;
|
||||
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;
|
||||
|
||||
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
Loading…
Reference in New Issue