core-jgi/migration/iD10/oracle/202202151954_IDEMPIERE-3595...

299 lines
164 KiB
MySQL
Raw Normal View History

-- IDEMPIERE-3595
SELECT register_migration_script('202202151954_IDEMPIERE-3595.sql') FROM dual;
SET SQLBLANKLINES ON
SET DEFINE OFF
-- Feb 15, 2022, 7:10:49 PM CET
UPDATE AD_ViewColumn SET ColumnSQL='COALESCE(l.postal,'''') || COALESCE(l.postal_add,'''')',Updated=TO_DATE('2022-02-15 19:10:49','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_ViewColumn_ID=200509
;
-- Feb 15, 2022, 7:11:46 PM CET
CREATE OR REPLACE VIEW C_Dunning_Header_v(AD_Client_ID, AD_Org_ID, IsActive, Created, CreatedBy, Updated, UpdatedBy, AD_Language, C_DunningRun_ID, C_DunningRunEntry_ID, DunningDate, PrintName, DocumentNote, C_BPartner_ID, BPValue, BPTaxID, NAICS, DUNS, Org_Location_ID, TaxID, SalesRep_ID, SalesRep_Name, BPGreeting, Name, Name2, BPContactGreeting, Title, Phone, ContactName, C_Location_ID, ReferenceNo, Postal, Amt, Qty, Note, Logo_ID, C_Dunning_ID, C_DunningRun_C_DunningLevel_ID, c_dunningrun_description, Processed, Processing, SendIt, C_DunningRunEntry_AD_Org_ID, AD_User_ID, C_BPartner_Location_ID, C_Currency_ID, C_DunRunEntry_C_DunLevel_ID, c_dunningrunentry_created, C_DunningRunEntry_CreatedBy, c_dunningrunentry_isactive, c_dunningrunentry_processed, c_dunningrunentry_updated, C_DunningRunEntry_UpdatedBy, C_DunningLevel_AD_Org_ID, C_DunningLevel_C_Dunning_ID, ChargeFee, ChargeInterest, C_PaymentTerm_ID, DaysAfterDue, DaysBetweenDunning, c_dunninglevel_description, Dunning_PrintFormat_ID, FeeAmt, InterestPercent, InvoiceCollectionType, c_dunninglevel_isactive, IsSetCreditStop, IsSetPaymentTerm, IsShowAllDue, IsShowNotDue, IsStatement, c_dunninglevel_name, c_bpartner_acqusitioncost, c_bpartner_actuallifetimevalue, c_bpartner_ad_language, C_BPartner_AD_OrgBP_ID, C_BPartner_AD_Org_ID, C_BPartner_BPartner_Parent_ID, C_BPartner_C_BP_Group_ID, C_BPartner_C_Greeting_ID, C_BPartner_InvoiceSchedule_ID, C_BPartner_C_PaymentTerm_ID, c_bpartner_created, C_BPartner_CreatedBy, C_BPartner_C_TaxGroup_ID, c_bpartner_deliveryrule, c_bpartner_deliveryviarule, c_bpartner_description, c_bpartner_dunninggrace, c_bpartner_firstsale, c_bpartner_flatdiscount, c_bpartner_freightcostrule, c_bpartner_invoicerule, c_bpartner_isactive, c_bpartner_iscustomer, c_bpartner_isdiscountprinted, c_bpartner_isemployee, c_bpartner_ismanufacturer, c_bpartner_isonetime, c_bpartner_ispotaxexempt, c_bpartner_isprospect, c_bpartner_issalesrep, c_bpartner_issummary, c_bpartner_istaxexempt, c_bpartner_isvendor, C_BPartner_Logo_ID, C_BPartner_M_DiscountSchema_ID, C_BPartner_M_PriceList_ID, c_bpartner_naics, c_bpartner_numberemployees, c_bpartner_paymentrule, c_bpartner_paymentrulepo, C_BPartnerPO_DiscountSchema_ID, C_BPartner_PO_PaymentTerm_ID, C_BPartner_PO_PriceList_ID, c_bpartner_poreference, c_bpartner_potentiallifetimev, c_bpartner_rating, C_BPartner_SalesRep_ID, c_bpartner_salesvolume, c_bpartner_sendemail,
c_bpartner_shareofcustomer, c_bpartner_shelflifeminpct, c_bpartner_so_creditlimit, c_bpartner_socreditstatus, c_bpartner_so_creditused, c_bpartner_so_description, c_bpartner_totalopenbalance, c_bpartner_updated, C_BPartner_UpdatedBy, c_bpartner_url, C_BPartner_Greeting_AD_Org_ID, c_bpartner_greeting_isactive, c_bpartner_greeting_isfirstna, c_bpartner_greeting_name, C_BPartner_Location_AD_Org_ID, c_bpartner_location_created, C_BPartner_Location_CreatedBy, C_SalesRegion_ID, c_bpartner_location_fax, c_bpartner_location_isactive, IsBillTo, ISDN, IsPayFrom, IsRemitTo, IsShipTo, c_bpartner_location_name, c_bpartner_location_phone, c_bpartner_location_phone2, c_bpartner_location_updated, C_BPartner_Location_UpdatedBy, Address1, Address2, Address3, Address4, C_Location_AD_Org_ID, C_City_ID, C_Country_ID, City, c_location_created, C_Location_CreatedBy, C_Region_ID, c_location_isactive, Postal_Add, RegionName, c_location_updated, C_Location_UpdatedBy, AD_User_AD_Org_ID, AD_User_AD_AD_OrgTrx_ID, ad_user_ad_birthday, AD_User_C_BPartner_ID, AD_User_C_BPartner_Location_ID, AD_User_C_Greeting_ID, ad_user_comments, ad_user_created, AD_User_CreatedBy, ad_user_description, ad_user_email, ad_user_fax, ad_user_isactive, ad_user_lastcontact, ad_user_lastresult, ad_user_name, ad_user_phone2, AD_User_Supervisor_ID, ad_user_updated, AD_User_UpdatedBy, ad_user_value, C_User_Greeting_AD_Org_ID, c_user_greeting_isactive, c_user_greeting_isfirstnameon, c_user_greeting_name, AD_OrgInfo_AD_Org_ID, AD_OrgType_ID, C_Calendar_ID, ad_orginfo_created, AD_OrgInfo_CreatedBy, DropShip_Warehouse_ID, ad_orginfo_duns, ad_orginfo_email, ad_orginfo_fax, ad_orginfo_isactive, M_Warehouse_ID, Parent_Org_ID, ad_orginfo_phone, ad_orginfo_phone2, ReceiptFooterMsg, Supervisor_ID, ad_orginfo_updated, AD_OrgInfo_UpdatedBy, SalesRep_AD_Org_ID, SalesRep_AD_AD_OrgTrx_ID, salesrep_ad_birthday, SalesRep_C_BPartner_ID, SalesRep_C_BP_Location_ID, SalesRep_C_Greeting_ID, salesrep_comments, salesrep_created, SalesRep_CreatedBy, salesrep_description, salesrep_email, salesrep_fax, salesrep_isactive, salesrep_lastcontact, salesrep_lastresult, salesrep_phone2, SalesRep_Supervisor_ID, salesrep_updated, SalesRep_UpdatedBy, salesrep_value, salesrep_bpartner_acqusitionc, salesrep_bpartner_actuallifet, salesrep_bpartner_ad_language, SalesRep_BPartner_AD_OrgBP_ID, SalesRep_BPartner_AD_Org_ID, SalesRep_BPartner_BP_Parent_ID, SalesRep_BP_C_BP_Group_ID,
SalesRep_BP_C_Greeting_ID, SalesRep_BP_InvoiceSchedule_ID, SalesRep_BP_C_PaymentTerm_ID, salesrep_bpartner_created, SalesRep_BPartner_CreatedBy, SalesRep_BP_C_TaxGroup_ID, salesrep_bpartner_deliveryrule, salesrep_bpartner_deliveryvia, salesrep_bpartner_description, salesrep_bpartner_dunninggrace, salesrep_bpartner_firstsale, salesrep_bpartner_flatdiscount, salesrep_bpartner_freightcost, salesrep_bpartner_invoicerule, salesrep_bpartner_isactive, salesrep_bpartner_iscustomer, salesrep_bpartner_isdiscountp, salesrep_bpartner_isemployee, salesrep_bpartner_ismanufactu, salesrep_bpartner_isonetime, salesrep_bpartner_ispotaxexem, salesrep_bpartner_isprospect, salesrep_bpartner_issalesrep, salesrep_bpartner_issummary, salesrep_bpartner_istaxexempt, salesrep_bpartner_isvendor, SalesRep_BPartner_Logo_ID, SalesRep_BP_MDiscountSchema_ID, SalesRep_BP_M_PriceList_ID, salesrep_bpartner_naics, salesrep_bpartner_numberemplo, salesrep_bpartner_paymentrule, salesrep_bpartner_paymentrupo, SalesRep_BP_PO_DiscountScm_ID, SalesRep_BP_PO_PaymentTerm_ID, SalesRep_BP_PO_PriceList_ID, salesrep_bpartner_poreference, salesrep_bpartner_potentialli, salesrep_bpartner_rating, SalesRep_BPartner_SalesRep_ID, salesrep_bpartner_salesvolume, salesrep_bpartner_sendemail, salesrep_bpartner_shareofcust, salesrep_bpartner_shelflifemi, salesrep_bpartner_so_creditli, salesrep_bpartner_socreditsta, salesrep_bpartner_so_creditus, salesrep_bpartner_so_descript, salesrep_bpartner_totalopenba, salesrep_bpartner_updated, SalesRep_BPartner_UpdatedBy, salesrep_bpartner_url) AS SELECT dr.ad_client_id AS AD_Client_ID, dr.ad_org_id AS AD_Org_ID, dr.isactive AS IsActive, dr.created AS Created, dr.createdby AS CreatedBy, dr.updated AS Updated, dr.updatedby AS UpdatedBy, CAST('en_US' AS CHARACTER VARYING(6)) AS AD_Language, dr.c_dunningrun_id AS C_DunningRun_ID, dre.c_dunningrunentry_id AS C_DunningRunEntry_ID, dr.dunningdate AS DunningDate, dl.printname AS PrintName, dl.note AS DocumentNote, dre.c_bpartner_id AS C_BPartner_ID, bp.value AS BPValue, bp.taxid AS BPTaxID, bp.naics AS NAICS, bp.duns AS DUNS, oi.c_location_id AS Org_Location_ID, oi.taxid AS TaxID, dre.salesrep_id AS SalesRep_ID, COALESCE(ubp.name, u.name) AS SalesRep_Name, bpg.greeting AS BPGreeting, bp.name AS Name, bp.name2 AS Name2, bpcg.greeting AS BPContactGreeting, bpc.title AS Title, bpc.phone AS Phone, NULLIF(bpc.name, bp.name) AS ContactName, bpl.c_location_id AS C_Location_ID,
bp.referenceno AS ReferenceNo, COALESCE(l.postal,'') || COALESCE(l.postal_add,'') AS Postal, dre.amt AS Amt, dre.qty AS Qty, dre.note AS Note, COALESCE(oi.logo_id, ci.logo_id) AS Logo_ID, dr.c_dunning_id AS C_Dunning_ID, dr.c_dunninglevel_id AS C_DunningRun_C_DunningLevel_ID, dr.description AS c_dunningrun_description, dr.processed AS Processed, dr.processing AS Processing, dr.sendit AS SendIt, dre.ad_org_id AS C_DunningRunEntry_AD_Org_ID, dre.ad_user_id AS AD_User_ID, dre.c_bpartner_location_id AS C_BPartner_Location_ID, dre.c_currency_id AS C_Currency_ID, dre.c_dunninglevel_id AS C_DunRunEntry_C_DunLevel_ID, dre.created AS c_dunningrunentry_created, dre.createdby AS C_DunningRunEntry_CreatedBy, dre.isactive AS c_dunningrunentry_isactive, dre.processed AS c_dunningrunentry_processed, dre.updated AS c_dunningrunentry_updated, dre.updatedby AS C_DunningRunEntry_UpdatedBy, dl.ad_org_id AS C_DunningLevel_AD_Org_ID, dl.c_dunning_id AS C_DunningLevel_C_Dunning_ID, dl.chargefee AS ChargeFee, dl.chargeinterest AS ChargeInterest, dl.c_paymentterm_id AS C_PaymentTerm_ID, dl.daysafterdue AS DaysAfterDue, dl.daysbetweendunning AS DaysBetweenDunning, dl.description AS c_dunninglevel_description, dl.dunning_printformat_id AS Dunning_PrintFormat_ID, dl.feeamt AS FeeAmt, dl.interestpercent AS InterestPercent, dl.invoicecollectiontype AS InvoiceCollectionType, dl.isactive AS c_dunninglevel_isactive, dl.issetcreditstop AS IsSetCreditStop, dl.issetpaymentterm AS IsSetPaymentTerm, dl.isshowalldue AS IsShowAllDue, dl.isshownotdue AS IsShowNotDue, dl.isstatement AS IsStatement, dl.name AS c_dunninglevel_name, bp.acqusitioncost AS c_bpartner_acqusitioncost, bp.actuallifetimevalue AS c_bpartner_actuallifetimevalue, bp.ad_language AS c_bpartner_ad_language, bp.ad_orgbp_id AS C_BPartner_AD_OrgBP_ID, bp.ad_org_id AS C_BPartner_AD_Org_ID, bp.bpartner_parent_id AS C_BPartner_BPartner_Parent_ID, bp.c_bp_group_id AS C_BPartner_C_BP_Group_ID, bp.c_greeting_id AS C_BPartner_C_Greeting_ID, bp.c_invoiceschedule_id AS C_BPartner_InvoiceSchedule_ID, bp.c_paymentterm_id AS C_BPartner_C_PaymentTerm_ID, bp.created AS c_bpartner_created, bp.createdby AS C_BPartner_CreatedBy, bp.c_taxgroup_id AS C_BPartner_C_TaxGroup_ID, bp.deliveryrule AS c_bpartner_deliveryrule, bp.deliveryviarule AS c_bpartner_deliveryviarule, bp.description AS c_bpartner_description, bp.dunninggrace AS c_bpartner_dunninggrace, bp.firstsale AS c_bpartner_firstsale,
bp.flatdiscount AS c_bpartner_flatdiscount, bp.freightcostrule AS c_bpartner_freightcostrule, bp.invoicerule AS c_bpartner_invoicerule, bp.isactive AS c_bpartner_isactive, bp.iscustomer AS c_bpartner_iscustomer, bp.isdiscountprinted AS c_bpartner_isdiscountprinted, bp.isemployee AS c_bpartner_isemployee, bp.ismanufacturer AS c_bpartner_ismanufacturer, bp.isonetime AS c_bpartner_isonetime, bp.ispotaxexempt AS c_bpartner_ispotaxexempt, bp.isprospect AS c_bpartner_isprospect, bp.issalesrep AS c_bpartner_issalesrep, bp.issummary AS c_bpartner_issummary, bp.istaxexempt AS c_bpartner_istaxexempt, bp.isvendor AS c_bpartner_isvendor, bp.logo_id AS C_BPartner_Logo_ID, bp.m_discountschema_id AS C_BPartner_M_DiscountSchema_ID, bp.m_pricelist_id AS C_BPartner_M_PriceList_ID, bp.naics AS c_bpartner_naics, bp.numberemployees AS c_bpartner_numberemployees, bp.paymentrule AS c_bpartner_paymentrule, bp.paymentrulepo AS c_bpartner_paymentrulepo, bp.po_discountschema_id AS C_BPartnerPO_DiscountSchema_ID, bp.po_paymentterm_id AS C_BPartner_PO_PaymentTerm_ID, bp.po_pricelist_id AS C_BPartner_PO_PriceList_ID, bp.poreference AS c_bpartner_poreference, bp.potentiallifetimevalue AS c_bpartner_potentiallifetimev, bp.rating AS c_bpartner_rating, bp.salesrep_id AS C_BPartner_SalesRep_ID, bp.salesvolume AS c_bpartner_salesvolume, bp.sendemail AS c_bpartner_sendemail, bp.shareofcustomer AS c_bpartner_shareofcustomer, bp.shelflifeminpct AS c_bpartner_shelflifeminpct, bp.so_creditlimit AS c_bpartner_so_creditlimit, bp.socreditstatus AS c_bpartner_socreditstatus, bp.so_creditused AS c_bpartner_so_creditused, bp.so_description AS c_bpartner_so_description, bp.totalopenbalance AS c_bpartner_totalopenbalance, bp.updated AS c_bpartner_updated, bp.updatedby AS C_BPartner_UpdatedBy, bp.url AS c_bpartner_url, bpg.ad_org_id AS C_BPartner_Greeting_AD_Org_ID, bpg.isactive AS c_bpartner_greeting_isactive, bpg.isfirstnameonly AS c_bpartner_greeting_isfirstna, bpg.name AS c_bpartner_greeting_name, bpl.ad_org_id AS C_BPartner_Location_AD_Org_ID, bpl.created AS c_bpartner_location_created, bpl.createdby AS C_BPartner_Location_CreatedBy, bpl.c_salesregion_id AS C_SalesRegion_ID, bpl.fax AS c_bpartner_location_fax, bpl.isactive AS c_bpartner_location_isactive, bpl.isbillto AS IsBillTo, bpl.isdn AS ISDN, bpl.ispayfrom AS IsPayFrom, bpl.isremitto AS IsRemitTo, bpl.isshipto AS IsShipTo, bpl.name AS c_bpartner_location_name,
bpl.phone AS c_bpartner_location_phone, bpl.phone2 AS c_bpartner_location_phone2, bpl.updated AS c_bpartner_location_updated, bpl.updatedby AS C_BPartner_Location_UpdatedBy, l.address1 AS Address1, l.address2 AS Address2, l.address3 AS Address3, l.address4 AS Address4, l.ad_org_id AS C_Location_AD_Org_ID, l.c_city_id AS C_City_ID, l.c_country_id AS C_Country_ID, l.city AS City, l.created AS c_location_created, l.createdby AS C_Location_CreatedBy, l.c_region_id AS C_Region_ID, l.isactive AS c_location_isactive, l.postal_add AS Postal_Add, l.regionname AS RegionName, l.updated AS c_location_updated, l.updatedby AS C_Location_UpdatedBy, bpc.ad_org_id AS AD_User_AD_Org_ID, bpc.ad_orgtrx_id AS AD_User_AD_AD_OrgTrx_ID, bpc.birthday AS ad_user_ad_birthday, bpc.c_bpartner_id AS AD_User_C_BPartner_ID, bpc.c_bpartner_location_id AS AD_User_C_BPartner_Location_ID, bpc.c_greeting_id AS AD_User_C_Greeting_ID, bpc.comments AS ad_user_comments, bpc.created AS ad_user_created, bpc.createdby AS AD_User_CreatedBy, bpc.description AS ad_user_description, bpc.email AS ad_user_email, bpc.fax AS ad_user_fax, bpc.isactive AS ad_user_isactive, bpc.lastcontact AS ad_user_lastcontact, bpc.lastresult AS ad_user_lastresult, bpc.name AS ad_user_name, bpc.phone2 AS ad_user_phone2, bpc.supervisor_id AS AD_User_Supervisor_ID, bpc.updated AS ad_user_updated, bpc.updatedby AS AD_User_UpdatedBy, bpc.value AS ad_user_value, bpcg.ad_org_id AS C_User_Greeting_AD_Org_ID, bpcg.isactive AS c_user_greeting_isactive, bpcg.isfirstnameonly AS c_user_greeting_isfirstnameon, bpcg.name AS c_user_greeting_name, oi.ad_org_id AS AD_OrgInfo_AD_Org_ID, oi.ad_orgtype_id AS AD_OrgType_ID, oi.c_calendar_id AS C_Calendar_ID, oi.created AS ad_orginfo_created, oi.createdby AS AD_OrgInfo_CreatedBy, oi.dropship_warehouse_id AS DropShip_Warehouse_ID, oi.duns AS ad_orginfo_duns, oi.email AS ad_orginfo_email, oi.fax AS ad_orginfo_fax, oi.isactive AS ad_orginfo_isactive, oi.m_warehouse_id AS M_Warehouse_ID, oi.parent_org_id AS Parent_Org_ID, oi.phone AS ad_orginfo_phone, oi.phone2 AS ad_orginfo_phone2, oi.receiptfootermsg AS ReceiptFooterMsg, oi.supervisor_id AS Supervisor_ID, oi.updated AS ad_orginfo_updated, oi.updatedby AS AD_OrgInfo_UpdatedBy, u.ad_org_id AS SalesRep_AD_Org_ID, u.ad_orgtrx_id AS SalesRep_AD_AD_OrgTrx_ID, u.birthday AS salesrep_ad_birthday, u.c_bpartner_id AS SalesRep_C_BPartner_ID, u.c_bpartner_location_id AS SalesRep_C_BP_Location_ID,
u.c_greeting_id AS SalesRep_C_Greeting_ID, u.comments AS salesrep_comments, u.created AS salesrep_created, u.createdby AS SalesRep_CreatedBy, u.description AS salesrep_description, u.email AS salesrep_email, u.fax AS salesrep_fax, u.isactive AS salesrep_isactive, u.lastcontact AS salesrep_lastcontact, u.lastresult AS salesrep_lastresult, u.phone2 AS salesrep_phone2, u.supervisor_id AS SalesRep_Supervisor_ID, u.updated AS salesrep_updated, u.updatedby AS SalesRep_UpdatedBy, u.value AS salesrep_value, ubp.acqusitioncost AS salesrep_bpartner_acqusitionc, ubp.actuallifetimevalue AS salesrep_bpartner_actuallifet, ubp.ad_language AS salesrep_bpartner_ad_language, ubp.ad_orgbp_id AS SalesRep_BPartner_AD_OrgBP_ID, ubp.ad_org_id AS SalesRep_BPartner_AD_Org_ID, ubp.bpartner_parent_id AS SalesRep_BPartner_BP_Parent_ID, ubp.c_bp_group_id AS SalesRep_BP_C_BP_Group_ID, ubp.c_greeting_id AS SalesRep_BP_C_Greeting_ID, ubp.c_invoiceschedule_id AS SalesRep_BP_InvoiceSchedule_ID, ubp.c_paymentterm_id AS SalesRep_BP_C_PaymentTerm_ID, ubp.created AS salesrep_bpartner_created, ubp.createdby AS SalesRep_BPartner_CreatedBy, ubp.c_taxgroup_id AS SalesRep_BP_C_TaxGroup_ID, ubp.deliveryrule AS salesrep_bpartner_deliveryrule, ubp.deliveryviarule AS salesrep_bpartner_deliveryvia, ubp.description AS salesrep_bpartner_description, ubp.dunninggrace AS salesrep_bpartner_dunninggrace, ubp.firstsale AS salesrep_bpartner_firstsale, ubp.flatdiscount AS salesrep_bpartner_flatdiscount, ubp.freightcostrule AS salesrep_bpartner_freightcost, ubp.invoicerule AS salesrep_bpartner_invoicerule, ubp.isactive AS salesrep_bpartner_isactive, ubp.iscustomer AS salesrep_bpartner_iscustomer, ubp.isdiscountprinted AS salesrep_bpartner_isdiscountp, ubp.isemployee AS salesrep_bpartner_isemployee, ubp.ismanufacturer AS salesrep_bpartner_ismanufactu, ubp.isonetime AS salesrep_bpartner_isonetime, ubp.ispotaxexempt AS salesrep_bpartner_ispotaxexem, ubp.isprospect AS salesrep_bpartner_isprospect, ubp.issalesrep AS salesrep_bpartner_issalesrep, ubp.issummary AS salesrep_bpartner_issummary, ubp.istaxexempt AS salesrep_bpartner_istaxexempt, ubp.isvendor AS salesrep_bpartner_isvendor, ubp.logo_id AS SalesRep_BPartner_Logo_ID, ubp.m_discountschema_id AS SalesRep_BP_MDiscountSchema_ID, ubp.m_pricelist_id AS SalesRep_BP_M_PriceList_ID, ubp.naics AS salesrep_bpartner_naics, ubp.numberemployees AS salesrep_bpartner_numberemplo,
ubp.paymentrule AS salesrep_bpartner_paymentrule, ubp.paymentrulepo AS salesrep_bpartner_paymentrupo, ubp.po_discountschema_id AS SalesRep_BP_PO_DiscountScm_ID, ubp.po_paymentterm_id AS SalesRep_BP_PO_PaymentTerm_ID, ubp.po_pricelist_id AS SalesRep_BP_PO_PriceList_ID, ubp.poreference AS salesrep_bpartner_poreference, ubp.potentiallifetimevalue AS salesrep_bpartner_potentialli, ubp.rating AS salesrep_bpartner_rating, ubp.salesrep_id AS SalesRep_BPartner_SalesRep_ID, ubp.salesvolume AS salesrep_bpartner_salesvolume, ubp.sendemail AS salesrep_bpartner_sendemail, ubp.shareofcustomer AS salesrep_bpartner_shareofcust, ubp.shelflifeminpct AS salesrep_bpartner_shelflifemi, ubp.so_creditlimit AS salesrep_bpartner_so_creditli, ubp.socreditstatus AS salesrep_bpartner_socreditsta, ubp.so_creditused AS salesrep_bpartner_so_creditus, ubp.so_description AS salesrep_bpartner_so_descript, ubp.totalopenbalance AS salesrep_bpartner_totalopenba, ubp.updated AS salesrep_bpartner_updated, ubp.updatedby AS SalesRep_BPartner_UpdatedBy, ubp.url AS salesrep_bpartner_url FROM c_dunningrun dr
JOIN c_dunningrunentry dre ON dr.c_dunningrun_id = dre.c_dunningrun_id
JOIN c_dunninglevel dl ON dre.c_dunninglevel_id = dl.c_dunninglevel_id
JOIN c_bpartner bp ON dre.c_bpartner_id = bp.c_bpartner_id
LEFT JOIN c_greeting bpg ON bp.c_greeting_id = bpg.c_greeting_id
JOIN c_bpartner_location bpl ON dre.c_bpartner_location_id = bpl.c_bpartner_location_id
JOIN c_location l ON bpl.c_location_id = l.c_location_id
LEFT JOIN ad_user bpc ON dre.ad_user_id = bpc.ad_user_id
LEFT JOIN c_greeting bpcg ON bpc.c_greeting_id = bpcg.c_greeting_id
JOIN ad_orginfo oi ON dr.ad_org_id = oi.ad_org_id
JOIN ad_clientinfo ci ON dr.ad_client_id = ci.ad_client_id
LEFT JOIN ad_user u ON dre.salesrep_id = u.ad_user_id
LEFT JOIN c_bpartner ubp ON u.c_bpartner_id = ubp.c_bpartner_id
;
-- Feb 15, 2022, 7:54:03 PM CET
UPDATE AD_ViewColumn SET ColumnSQL='COALESCE(l.postal,'''') || COALESCE(l.postal_add,'''')',Updated=TO_DATE('2022-02-15 19:54:03','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_ViewColumn_ID=200798
;
-- Feb 15, 2022, 7:54:22 PM CET
CREATE OR REPLACE VIEW C_Dunning_Header_vt(AD_Client_ID, AD_Org_ID, IsActive, Created, CreatedBy, Updated, UpdatedBy, AD_Language, C_DunningRun_ID, C_DunningRunEntry_ID, DunningDate, PrintName, DocumentNote, C_BPartner_ID, BPValue, BPTaxID, NAICS, DUNS, Org_Location_ID, TaxID, SalesRep_ID, SalesRep_Name, BPGreeting, Name, Name2, BPContactGreeting, Title, Phone, ContactName, C_Location_ID, ReferenceNo, Postal, Amt, Qty, Note, Logo_ID, C_Dunning_ID, C_DunningRun_C_DunningLevel_ID, c_dunningrun_description, Processed, Processing, SendIt, C_DunningRunEntry_AD_Org_ID, AD_User_ID, C_BPartner_Location_ID, C_Currency_ID, C_DunRunEntry_C_DunLevel_ID, c_dunningrunentry_created, C_DunningRunEntry_CreatedBy, c_dunningrunentry_isactive, c_dunningrunentry_processed, c_dunningrunentry_updated, C_DunningRunEntry_UpdatedBy, C_DunningLevel_AD_Org_ID, C_DunningLevel_C_Dunning_ID, ChargeFee, ChargeInterest, C_PaymentTerm_ID, DaysAfterDue, DaysBetweenDunning, c_dunninglevel_description, Dunning_PrintFormat_ID, FeeAmt, InterestPercent, InvoiceCollectionType, c_dunninglevel_isactive, IsSetCreditStop, IsSetPaymentTerm, IsShowAllDue, IsShowNotDue, IsStatement, c_dunninglevel_name, c_bpartner_acqusitioncost, c_bpartner_actuallifetimevalue, c_bpartner_ad_language, C_BPartner_AD_OrgBP_ID, C_BPartner_AD_Org_ID, C_BPartner_BPartner_Parent_ID, C_BPartner_C_BP_Group_ID, C_BPartner_C_Greeting_ID, C_BPartner_InvoiceSchedule_ID, C_BPartner_C_PaymentTerm_ID, c_bpartner_created, C_BPartner_CreatedBy, C_BPartner_C_TaxGroup_ID, c_bpartner_deliveryrule, c_bpartner_deliveryviarule, c_bpartner_description, c_bpartner_dunninggrace, c_bpartner_firstsale, c_bpartner_flatdiscount, c_bpartner_freightcostrule, c_bpartner_invoicerule, c_bpartner_isactive, c_bpartner_iscustomer, c_bpartner_isdiscountprinted, c_bpartner_isemployee, c_bpartner_ismanufacturer, c_bpartner_isonetime, c_bpartner_ispotaxexempt, c_bpartner_isprospect, c_bpartner_issalesrep, c_bpartner_issummary, c_bpartner_istaxexempt, c_bpartner_isvendor, C_BPartner_Logo_ID, C_BPartner_M_DiscountSchema_ID, C_BPartner_M_PriceList_ID, c_bpartner_naics, c_bpartner_numberemployees, c_bpartner_paymentrule, c_bpartner_paymentrulepo, C_BPartnerPO_DiscountSchema_ID, C_BPartner_PO_PaymentTerm_ID, C_BPartner_PO_PriceList_ID, c_bpartner_poreference, c_bpartner_potentiallifetimev, c_bpartner_rating, C_BPartner_SalesRep_ID, c_bpartner_salesvolume, c_bpartner_sendemail,
c_bpartner_shareofcustomer, c_bpartner_shelflifeminpct, c_bpartner_so_creditlimit, c_bpartner_socreditstatus, c_bpartner_so_creditused, c_bpartner_so_description, c_bpartner_totalopenbalance, c_bpartner_updated, C_BPartner_UpdatedBy, c_bpartner_url, C_BPartner_Greeting_AD_Org_ID, c_bpartner_greeting_isactive, c_bpartner_greeting_isfirstna, c_bpartner_greeting_name, C_BPartner_Location_AD_Org_ID, c_bpartner_location_created, C_BPartner_Location_CreatedBy, C_SalesRegion_ID, c_bpartner_location_fax, c_bpartner_location_isactive, IsBillTo, ISDN, IsPayFrom, IsRemitTo, IsShipTo, c_bpartner_location_name, c_bpartner_location_phone, c_bpartner_location_phone2, c_bpartner_location_updated, C_BPartner_Location_UpdatedBy, Address1, Address2, Address3, Address4, C_Location_AD_Org_ID, C_City_ID, C_Country_ID, City, c_location_created, C_Location_CreatedBy, C_Region_ID, c_location_isactive, Postal_Add, RegionName, c_location_updated, C_Location_UpdatedBy, AD_User_AD_Org_ID, AD_User_AD_AD_OrgTrx_ID, ad_user_ad_birthday, AD_User_C_BPartner_ID, AD_User_C_BPartner_Location_ID, AD_User_C_Greeting_ID, ad_user_comments, ad_user_created, AD_User_CreatedBy, ad_user_description, ad_user_email, ad_user_fax, ad_user_isactive, ad_user_lastcontact, ad_user_lastresult, ad_user_name, ad_user_phone2, AD_User_Supervisor_ID, ad_user_updated, AD_User_UpdatedBy, ad_user_value, C_User_Greeting_AD_Org_ID, c_user_greeting_isactive, c_user_greeting_isfirstnameon, c_user_greeting_name, AD_OrgInfo_AD_Org_ID, AD_OrgType_ID, C_Calendar_ID, ad_orginfo_created, AD_OrgInfo_CreatedBy, DropShip_Warehouse_ID, ad_orginfo_duns, ad_orginfo_email, ad_orginfo_fax, ad_orginfo_isactive, M_Warehouse_ID, Parent_Org_ID, ad_orginfo_phone, ad_orginfo_phone2, ReceiptFooterMsg, Supervisor_ID, ad_orginfo_updated, AD_OrgInfo_UpdatedBy, SalesRep_AD_Org_ID, SalesRep_AD_AD_OrgTrx_ID, salesrep_ad_birthday, SalesRep_C_BPartner_ID, SalesRep_C_BP_Location_ID, SalesRep_C_Greeting_ID, salesrep_comments, salesrep_created, SalesRep_CreatedBy, salesrep_description, salesrep_email, salesrep_fax, salesrep_isactive, salesrep_lastcontact, salesrep_lastresult, salesrep_phone2, SalesRep_Supervisor_ID, salesrep_updated, SalesRep_UpdatedBy, salesrep_value, salesrep_bpartner_acqusitionc, salesrep_bpartner_actuallifet, salesrep_bpartner_ad_language, SalesRep_BPartner_AD_OrgBP_ID, SalesRep_BPartner_AD_Org_ID, SalesRep_BPartner_BP_Parent_ID, SalesRep_BP_C_BP_Group_ID,
SalesRep_BP_C_Greeting_ID, SalesRep_BP_InvoiceSchedule_ID, SalesRep_BP_C_PaymentTerm_ID, salesrep_bpartner_created, SalesRep_BPartner_CreatedBy, SalesRep_BP_C_TaxGroup_ID, salesrep_bpartner_deliveryrule, salesrep_bpartner_deliveryvia, salesrep_bpartner_description, salesrep_bpartner_dunninggrace, salesrep_bpartner_firstsale, salesrep_bpartner_flatdiscount, salesrep_bpartner_freightcost, salesrep_bpartner_invoicerule, salesrep_bpartner_isactive, salesrep_bpartner_iscustomer, salesrep_bpartner_isdiscountp, salesrep_bpartner_isemployee, salesrep_bpartner_ismanufactu, salesrep_bpartner_isonetime, salesrep_bpartner_ispotaxexem, salesrep_bpartner_isprospect, salesrep_bpartner_issalesrep, salesrep_bpartner_issummary, salesrep_bpartner_istaxexempt, salesrep_bpartner_isvendor, SalesRep_BPartner_Logo_ID, SalesRep_BP_MDiscountSchema_ID, SalesRep_BP_M_PriceList_ID, salesrep_bpartner_naics, salesrep_bpartner_numberemplo, salesrep_bpartner_paymentrule, salesrep_bpartner_paymentrupo, SalesRep_BP_PO_DiscountScm_ID, SalesRep_BP_PO_PaymentTerm_ID, SalesRep_BP_PO_PriceList_ID, salesrep_bpartner_poreference, salesrep_bpartner_potentialli, salesrep_bpartner_rating, SalesRep_BPartner_SalesRep_ID, salesrep_bpartner_salesvolume, salesrep_bpartner_sendemail, salesrep_bpartner_shareofcust, salesrep_bpartner_shelflifemi, salesrep_bpartner_so_creditli, salesrep_bpartner_socreditsta, salesrep_bpartner_so_creditus, salesrep_bpartner_so_descript, salesrep_bpartner_totalopenba, salesrep_bpartner_updated, SalesRep_BPartner_UpdatedBy, salesrep_bpartner_url) AS SELECT dr.ad_client_id AS AD_Client_ID, dr.ad_org_id AS AD_Org_ID, dr.isactive AS IsActive, dr.created AS Created, dr.createdby AS CreatedBy, dr.updated AS Updated, dr.updatedby AS UpdatedBy, dlt.ad_language AS AD_Language, dr.c_dunningrun_id AS C_DunningRun_ID, dre.c_dunningrunentry_id AS C_DunningRunEntry_ID, dr.dunningdate AS DunningDate, dlt.printname AS PrintName, dlt.note AS DocumentNote, dre.c_bpartner_id AS C_BPartner_ID, bp.value AS BPValue, bp.taxid AS BPTaxID, bp.naics AS NAICS, bp.duns AS DUNS, oi.c_location_id AS Org_Location_ID, oi.taxid AS TaxID, dre.salesrep_id AS SalesRep_ID, COALESCE(ubp.name, u.name) AS SalesRep_Name, bpgt.greeting AS BPGreeting, bp.name AS Name, bp.name2 AS Name2, bpcgt.greeting AS BPContactGreeting, bpc.title AS Title, bpc.phone AS Phone, NULLIF(bpc.name, bp.name) AS ContactName, bpl.c_location_id AS C_Location_ID,
bp.referenceno AS ReferenceNo, COALESCE(l.postal,'') || COALESCE(l.postal_add,'') AS Postal, dre.amt AS Amt, dre.qty AS Qty, dre.note AS Note, COALESCE(oi.logo_id, ci.logo_id) AS Logo_ID, dr.c_dunning_id AS C_Dunning_ID, dr.c_dunninglevel_id AS C_DunningRun_C_DunningLevel_ID, dr.description AS c_dunningrun_description, dr.processed AS Processed, dr.processing AS Processing, dr.sendit AS SendIt, dre.ad_org_id AS C_DunningRunEntry_AD_Org_ID, dre.ad_user_id AS AD_User_ID, dre.c_bpartner_location_id AS C_BPartner_Location_ID, dre.c_currency_id AS C_Currency_ID, dre.c_dunninglevel_id AS C_DunRunEntry_C_DunLevel_ID, dre.created AS c_dunningrunentry_created, dre.createdby AS C_DunningRunEntry_CreatedBy, dre.isactive AS c_dunningrunentry_isactive, dre.processed AS c_dunningrunentry_processed, dre.updated AS c_dunningrunentry_updated, dre.updatedby AS C_DunningRunEntry_UpdatedBy, dl.ad_org_id AS C_DunningLevel_AD_Org_ID, dl.c_dunning_id AS C_DunningLevel_C_Dunning_ID, dl.chargefee AS ChargeFee, dl.chargeinterest AS ChargeInterest, dl.c_paymentterm_id AS C_PaymentTerm_ID, dl.daysafterdue AS DaysAfterDue, dl.daysbetweendunning AS DaysBetweenDunning, dl.description AS c_dunninglevel_description, dl.dunning_printformat_id AS Dunning_PrintFormat_ID, dl.feeamt AS FeeAmt, dl.interestpercent AS InterestPercent, dl.invoicecollectiontype AS InvoiceCollectionType, dl.isactive AS c_dunninglevel_isactive, dl.issetcreditstop AS IsSetCreditStop, dl.issetpaymentterm AS IsSetPaymentTerm, dl.isshowalldue AS IsShowAllDue, dl.isshownotdue AS IsShowNotDue, dl.isstatement AS IsStatement, dl.name AS c_dunninglevel_name, bp.acqusitioncost AS c_bpartner_acqusitioncost, bp.actuallifetimevalue AS c_bpartner_actuallifetimevalue, bp.ad_language AS c_bpartner_ad_language, bp.ad_orgbp_id AS C_BPartner_AD_OrgBP_ID, bp.ad_org_id AS C_BPartner_AD_Org_ID, bp.bpartner_parent_id AS C_BPartner_BPartner_Parent_ID, bp.c_bp_group_id AS C_BPartner_C_BP_Group_ID, bp.c_greeting_id AS C_BPartner_C_Greeting_ID, bp.c_invoiceschedule_id AS C_BPartner_InvoiceSchedule_ID, bp.c_paymentterm_id AS C_BPartner_C_PaymentTerm_ID, bp.created AS c_bpartner_created, bp.createdby AS C_BPartner_CreatedBy, bp.c_taxgroup_id AS C_BPartner_C_TaxGroup_ID, bp.deliveryrule AS c_bpartner_deliveryrule, bp.deliveryviarule AS c_bpartner_deliveryviarule, bp.description AS c_bpartner_description, bp.dunninggrace AS c_bpartner_dunninggrace, bp.firstsale AS c_bpartner_firstsale,
bp.flatdiscount AS c_bpartner_flatdiscount, bp.freightcostrule AS c_bpartner_freightcostrule, bp.invoicerule AS c_bpartner_invoicerule, bp.isactive AS c_bpartner_isactive, bp.iscustomer AS c_bpartner_iscustomer, bp.isdiscountprinted AS c_bpartner_isdiscountprinted, bp.isemployee AS c_bpartner_isemployee, bp.ismanufacturer AS c_bpartner_ismanufacturer, bp.isonetime AS c_bpartner_isonetime, bp.ispotaxexempt AS c_bpartner_ispotaxexempt, bp.isprospect AS c_bpartner_isprospect, bp.issalesrep AS c_bpartner_issalesrep, bp.issummary AS c_bpartner_issummary, bp.istaxexempt AS c_bpartner_istaxexempt, bp.isvendor AS c_bpartner_isvendor, bp.logo_id AS C_BPartner_Logo_ID, bp.m_discountschema_id AS C_BPartner_M_DiscountSchema_ID, bp.m_pricelist_id AS C_BPartner_M_PriceList_ID, bp.naics AS c_bpartner_naics, bp.numberemployees AS c_bpartner_numberemployees, bp.paymentrule AS c_bpartner_paymentrule, bp.paymentrulepo AS c_bpartner_paymentrulepo, bp.po_discountschema_id AS C_BPartnerPO_DiscountSchema_ID, bp.po_paymentterm_id AS C_BPartner_PO_PaymentTerm_ID, bp.po_pricelist_id AS C_BPartner_PO_PriceList_ID, bp.poreference AS c_bpartner_poreference, bp.potentiallifetimevalue AS c_bpartner_potentiallifetimev, bp.rating AS c_bpartner_rating, bp.salesrep_id AS C_BPartner_SalesRep_ID, bp.salesvolume AS c_bpartner_salesvolume, bp.sendemail AS c_bpartner_sendemail, bp.shareofcustomer AS c_bpartner_shareofcustomer, bp.shelflifeminpct AS c_bpartner_shelflifeminpct, bp.so_creditlimit AS c_bpartner_so_creditlimit, bp.socreditstatus AS c_bpartner_socreditstatus, bp.so_creditused AS c_bpartner_so_creditused, bp.so_description AS c_bpartner_so_description, bp.totalopenbalance AS c_bpartner_totalopenbalance, bp.updated AS c_bpartner_updated, bp.updatedby AS C_BPartner_UpdatedBy, bp.url AS c_bpartner_url, bpgt.ad_org_id AS C_BPartner_Greeting_AD_Org_ID, bpgt.isactive AS c_bpartner_greeting_isactive, bpg.isfirstnameonly AS c_bpartner_greeting_isfirstna, bpgt.name AS c_bpartner_greeting_name, bpl.ad_org_id AS C_BPartner_Location_AD_Org_ID, bpl.created AS c_bpartner_location_created, bpl.createdby AS C_BPartner_Location_CreatedBy, bpl.c_salesregion_id AS C_SalesRegion_ID, bpl.fax AS c_bpartner_location_fax, bpl.isactive AS c_bpartner_location_isactive, bpl.isbillto AS IsBillTo, bpl.isdn AS ISDN, bpl.ispayfrom AS IsPayFrom, bpl.isremitto AS IsRemitTo, bpl.isshipto AS IsShipTo, bpl.name AS c_bpartner_location_name,
bpl.phone AS c_bpartner_location_phone, bpl.phone2 AS c_bpartner_location_phone2, bpl.updated AS c_bpartner_location_updated, bpl.updatedby AS C_BPartner_Location_UpdatedBy, l.address1 AS Address1, l.address2 AS Address2, l.address3 AS Address3, l.address4 AS Address4, l.ad_org_id AS C_Location_AD_Org_ID, l.c_city_id AS C_City_ID, l.c_country_id AS C_Country_ID, l.city AS City, l.created AS c_location_created, l.createdby AS C_Location_CreatedBy, l.c_region_id AS C_Region_ID, l.isactive AS c_location_isactive, l.postal_add AS Postal_Add, l.regionname AS RegionName, l.updated AS c_location_updated, l.updatedby AS C_Location_UpdatedBy, bpc.ad_org_id AS AD_User_AD_Org_ID, bpc.ad_orgtrx_id AS AD_User_AD_AD_OrgTrx_ID, bpc.birthday AS ad_user_ad_birthday, bpc.c_bpartner_id AS AD_User_C_BPartner_ID, bpc.c_bpartner_location_id AS AD_User_C_BPartner_Location_ID, bpc.c_greeting_id AS AD_User_C_Greeting_ID, bpc.comments AS ad_user_comments, bpc.created AS ad_user_created, bpc.createdby AS AD_User_CreatedBy, bpc.description AS ad_user_description, bpc.email AS ad_user_email, bpc.fax AS ad_user_fax, bpc.isactive AS ad_user_isactive, bpc.lastcontact AS ad_user_lastcontact, bpc.lastresult AS ad_user_lastresult, bpc.name AS ad_user_name, bpc.phone2 AS ad_user_phone2, bpc.supervisor_id AS AD_User_Supervisor_ID, bpc.updated AS ad_user_updated, bpc.updatedby AS AD_User_UpdatedBy, bpc.value AS ad_user_value, bpcgt.ad_org_id AS C_User_Greeting_AD_Org_ID, bpcgt.isactive AS c_user_greeting_isactive, bpcg.isfirstnameonly AS c_user_greeting_isfirstnameon, bpcgt.name AS c_user_greeting_name, oi.ad_org_id AS AD_OrgInfo_AD_Org_ID, oi.ad_orgtype_id AS AD_OrgType_ID, oi.c_calendar_id AS C_Calendar_ID, oi.created AS ad_orginfo_created, oi.createdby AS AD_OrgInfo_CreatedBy, oi.dropship_warehouse_id AS DropShip_Warehouse_ID, oi.duns AS ad_orginfo_duns, oi.email AS ad_orginfo_email, oi.fax AS ad_orginfo_fax, oi.isactive AS ad_orginfo_isactive, oi.m_warehouse_id AS M_Warehouse_ID, oi.parent_org_id AS Parent_Org_ID, oi.phone AS ad_orginfo_phone, oi.phone2 AS ad_orginfo_phone2, oi.receiptfootermsg AS ReceiptFooterMsg, oi.supervisor_id AS Supervisor_ID, oi.updated AS ad_orginfo_updated, oi.updatedby AS AD_OrgInfo_UpdatedBy, u.ad_org_id AS SalesRep_AD_Org_ID, u.ad_orgtrx_id AS SalesRep_AD_AD_OrgTrx_ID, u.birthday AS salesrep_ad_birthday, u.c_bpartner_id AS SalesRep_C_BPartner_ID, u.c_bpartner_location_id AS SalesRep_C_BP_Location_ID,
u.c_greeting_id AS SalesRep_C_Greeting_ID, u.comments AS salesrep_comments, u.created AS salesrep_created, u.createdby AS SalesRep_CreatedBy, u.description AS salesrep_description, u.email AS salesrep_email, u.fax AS salesrep_fax, u.isactive AS salesrep_isactive, u.lastcontact AS salesrep_lastcontact, u.lastresult AS salesrep_lastresult, u.phone2 AS salesrep_phone2, u.supervisor_id AS SalesRep_Supervisor_ID, u.updated AS salesrep_updated, u.updatedby AS SalesRep_UpdatedBy, u.value AS salesrep_value, ubp.acqusitioncost AS salesrep_bpartner_acqusitionc, ubp.actuallifetimevalue AS salesrep_bpartner_actuallifet, ubp.ad_language AS salesrep_bpartner_ad_language, ubp.ad_orgbp_id AS SalesRep_BPartner_AD_OrgBP_ID, ubp.ad_org_id AS SalesRep_BPartner_AD_Org_ID, ubp.bpartner_parent_id AS SalesRep_BPartner_BP_Parent_ID, ubp.c_bp_group_id AS SalesRep_BP_C_BP_Group_ID, ubp.c_greeting_id AS SalesRep_BP_C_Greeting_ID, ubp.c_invoiceschedule_id AS SalesRep_BP_InvoiceSchedule_ID, ubp.c_paymentterm_id AS SalesRep_BP_C_PaymentTerm_ID, ubp.created AS salesrep_bpartner_created, ubp.createdby AS SalesRep_BPartner_CreatedBy, ubp.c_taxgroup_id AS SalesRep_BP_C_TaxGroup_ID, ubp.deliveryrule AS salesrep_bpartner_deliveryrule, ubp.deliveryviarule AS salesrep_bpartner_deliveryvia, ubp.description AS salesrep_bpartner_description, ubp.dunninggrace AS salesrep_bpartner_dunninggrace, ubp.firstsale AS salesrep_bpartner_firstsale, ubp.flatdiscount AS salesrep_bpartner_flatdiscount, ubp.freightcostrule AS salesrep_bpartner_freightcost, ubp.invoicerule AS salesrep_bpartner_invoicerule, ubp.isactive AS salesrep_bpartner_isactive, ubp.iscustomer AS salesrep_bpartner_iscustomer, ubp.isdiscountprinted AS salesrep_bpartner_isdiscountp, ubp.isemployee AS salesrep_bpartner_isemployee, ubp.ismanufacturer AS salesrep_bpartner_ismanufactu, ubp.isonetime AS salesrep_bpartner_isonetime, ubp.ispotaxexempt AS salesrep_bpartner_ispotaxexem, ubp.isprospect AS salesrep_bpartner_isprospect, ubp.issalesrep AS salesrep_bpartner_issalesrep, ubp.issummary AS salesrep_bpartner_issummary, ubp.istaxexempt AS salesrep_bpartner_istaxexempt, ubp.isvendor AS salesrep_bpartner_isvendor, ubp.logo_id AS SalesRep_BPartner_Logo_ID, ubp.m_discountschema_id AS SalesRep_BP_MDiscountSchema_ID, ubp.m_pricelist_id AS SalesRep_BP_M_PriceList_ID, ubp.naics AS salesrep_bpartner_naics, ubp.numberemployees AS salesrep_bpartner_numberemplo,
ubp.paymentrule AS salesrep_bpartner_paymentrule, ubp.paymentrulepo AS salesrep_bpartner_paymentrupo, ubp.po_discountschema_id AS SalesRep_BP_PO_DiscountScm_ID, ubp.po_paymentterm_id AS SalesRep_BP_PO_PaymentTerm_ID, ubp.po_pricelist_id AS SalesRep_BP_PO_PriceList_ID, ubp.poreference AS salesrep_bpartner_poreference, ubp.potentiallifetimevalue AS salesrep_bpartner_potentialli, ubp.rating AS salesrep_bpartner_rating, ubp.salesrep_id AS SalesRep_BPartner_SalesRep_ID, ubp.salesvolume AS salesrep_bpartner_salesvolume, ubp.sendemail AS salesrep_bpartner_sendemail, ubp.shareofcustomer AS salesrep_bpartner_shareofcust, ubp.shelflifeminpct AS salesrep_bpartner_shelflifemi, ubp.so_creditlimit AS salesrep_bpartner_so_creditli, ubp.socreditstatus AS salesrep_bpartner_socreditsta, ubp.so_creditused AS salesrep_bpartner_so_creditus, ubp.so_description AS salesrep_bpartner_so_descript, ubp.totalopenbalance AS salesrep_bpartner_totalopenba, ubp.updated AS salesrep_bpartner_updated, ubp.updatedby AS SalesRep_BPartner_UpdatedBy, ubp.url AS salesrep_bpartner_url FROM c_dunningrun dr
JOIN c_dunningrunentry dre ON dr.c_dunningrun_id = dre.c_dunningrun_id
JOIN c_dunninglevel dl ON dre.c_dunninglevel_id = dl.c_dunninglevel_id
JOIN c_dunninglevel_trl dlt ON dl.c_dunninglevel_id = dlt.c_dunninglevel_id
JOIN c_bpartner bp ON dre.c_bpartner_id = bp.c_bpartner_id
LEFT JOIN c_greeting bpg ON bp.c_greeting_id = bpg.c_greeting_id
LEFT JOIN c_greeting_trl bpgt ON bp.c_greeting_id = bpgt.c_greeting_id AND dlt.ad_language = bpgt.ad_language
JOIN c_bpartner_location bpl ON dre.c_bpartner_location_id = bpl.c_bpartner_location_id
JOIN c_location l ON bpl.c_location_id = l.c_location_id
LEFT JOIN ad_user bpc ON dre.ad_user_id = bpc.ad_user_id
LEFT JOIN c_greeting bpcg ON bpc.c_greeting_id = bpcg.c_greeting_id
LEFT JOIN c_greeting_trl bpcgt ON bpc.c_greeting_id = bpcgt.c_greeting_id AND dlt.ad_language = bpcgt.ad_language
JOIN ad_orginfo oi ON dr.ad_org_id = oi.ad_org_id
JOIN ad_clientinfo ci ON dr.ad_client_id = ci.ad_client_id
LEFT JOIN ad_user u ON dre.salesrep_id = u.ad_user_id
LEFT JOIN c_bpartner ubp ON u.c_bpartner_id = ubp.c_bpartner_id
;
-- Feb 15, 2022, 7:57:39 PM CET
UPDATE AD_ViewColumn SET ColumnSQL='COALESCE(l.postal,'''') || COALESCE(l.postal_add,'''')',Updated=TO_DATE('2022-02-15 19:57:39','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_ViewColumn_ID=201425
;
-- Feb 15, 2022, 7:58:06 PM CET
CREATE OR REPLACE VIEW C_Invoice_Header_v(AD_Client_ID, AD_Org_ID, IsActive, Created, CreatedBy, Updated, UpdatedBy, AD_Language, C_Invoice_ID, IsSOTrx, DocumentNo, DocStatus, C_DocType_ID, C_BPartner_ID, BPValue, BPTaxID, NAICS, DUNS, Org_Location_ID, TaxID, DocumentType, DocumentTypeNote, C_Order_ID, SalesRep_ID, SalesRep_Name, DateInvoiced, BPGreeting, Name, Name2, BPContactGreeting, Title, Phone, ContactName, C_Location_ID, ReferenceNo, Postal, Description, POReference, DateOrdered, C_Currency_ID, PaymentTerm, PaymentTermNote, C_Charge_ID, ChargeAmt, TotalLines, GrandTotal, AmtInWords, M_PriceList_ID, IsTaxIncluded, C_Campaign_ID, C_Project_ID, C_Activity_ID, IsPaid, Logo_ID, C_Invoice_AD_OrgTrx_ID, AD_User_ID, C_BPartner_Location_ID, C_ConversionType_ID, C_DocTypeTarget_ID, C_DunningLevel_ID, C_Payment_ID, DateAcct, DatePrinted, DocAction, DunningGrace, GenerateTo, InvoiceCollectionType, IsApproved, IsDiscountPrinted, IsInDispute, IsPayScheduleValid, IsPrinted, c_invoice_isselfservice, IsTransferred, M_RMA_ID, PaymentRule, Posted, ProcessedOn, Processing, Ref_Invoice_ID, Reversal_ID, SendEMail, User1_ID, User2_ID, C_PaymentTerm_AD_Org_ID, AfterDelivery, C_PaymentTerm_ID, c_paymentterm_description, Discount, Discount2, DiscountDays, DiscountDays2, FixMonthCutoff, FixMonthDay, FixMonthOffset, GraceDays, c_paymentterm_isactive, IsDefault, IsDueFixed, IsNextBusinessDay, IsValid, NetDay, NetDays, PaymentTermUsage, c_paymentterm_value, bp_acqusitioncost, bp_actuallifetimevalue, bp_ad_language, BP_AD_OrgBP_ID, BP_AD_Org_ID, BP_BPartner_Parent_ID, BP_C_BP_Group_ID, BP_C_Dunning_ID, BP_C_Greeting_ID, BP_C_InvoiceSchedule_ID, BP_C_PaymentTerm_ID, bp_created, BP_CreatedBy, BP_C_TaxGroup_ID, bp_deliveryrule, bp_deliveryviarule, bp_description, bp_dunninggrace, bp_firstsale, bp_flatdiscount, bp_freightcostrule, bp_invoicerule, bp_isactive, bp_iscustomer, bp_isdiscountprinted, bp_isemployee, bp_ismanufacturer, bp_isonetime, bp_ispotaxexempt, bp_isprospect, bp_issalesrep, bp_issummary, bp_istaxexempt, bp_isvendor, BP_Logo_ID, BP_M_DiscountSchema_ID, BP_M_PriceList_ID, bp_naics, bp_numberemployees, bp_paymentrule, bp_paymentrulepo, BP_PO_DiscountSchema_ID, BP_PO_PaymentTerm_ID, BP_PO_PriceList_ID, bp_poreference, bp_potentiallifetimevalue, bp_rating, BP_SalesRep_ID, bp_salesvolume, bp_sendemail, bp_shareofcustomer, bp_shelflifeminpct, bp_so_creditlimit, bp_socreditstatus,
bp_so_creditused, bp_so_description, bp_totalopenbalance, bp_updated, BP_UpdatedBy, bp_url, c_greeting_isactive, IsFirstNameOnly, c_greeting_name, BP_Location_AD_Org_ID, BP_Location_C_BPartner_ID, bp_location_created, BP_Location_CreatedBy, C_SalesRegion_ID, bp_location_fax, bp_location_isactive, IsBillTo, ISDN, IsPayFrom, IsRemitTo, IsShipTo, bp_location_name, bp_location_phone, bp_location_phone2, bp_location_updated, BP_Location_UpdatedBy, Address1, Address2, Address3, Address4, C_Location_AD_Org_ID, C_City_ID, C_Country_ID, City, c_location_created, C_Location_CreatedBy, C_Region_ID, c_location_isactive, RegionName, c_location_updated, C_Location_UpdatedBy, AD_User_AD_Org_ID, AD_User_AD_AD_OrgTrx_ID, ad_user_ad_birthday, AD_User_C_BPartner_ID, AD_User_C_BPartner_Location_ID, AD_User_C_Greeting_ID, ad_user_comments, ad_user_created, AD_User_CreatedBy, ad_user_description, ad_user_email, ad_user_fax, ad_user_isactive, ad_user_lastcontact, ad_user_lastresult, ad_user_phone2, AD_User_Supervisor_ID, ad_user_updated, AD_User_UpdatedBy, ad_user_value, user_greeting_isactive, user_greeting_isfirstnameonly, user_greeting_name, AD_OrgInfo_AD_Org_ID, AD_OrgType_ID, C_Calendar_ID, ad_orginfo_created, AD_OrgInfo_CreatedBy, DropShip_Warehouse_ID, ad_orginfo_duns, ad_orginfo_email, ad_orginfo_fax, ad_orginfo_isactive, M_Warehouse_ID, Parent_Org_ID, ad_orginfo_phone, ad_orginfo_phone2, ReceiptFooterMsg, Supervisor_ID, ad_orginfo_updated, AD_OrgInfo_UpdatedBy, SalesRep_AD_Org_ID, SalesRep_AD_AD_OrgTrx_ID, salesrep_ad_birthday, SalesRep_C_BPartner_ID, SalesRep_C_BP_Location_ID, SalesRep_C_Greeting_ID, salesrep_comments, salesrep_created, SalesRep_CreatedBy, salesrep_description, salesrep_email, salesrep_fax, salesrep_isactive, salesrep_lastcontact, salesrep_lastresult, salesrep_phone, salesrep_phone2, SalesRep_Supervisor_ID, salesrep_title, salesrep_updated, SalesRep_UpdatedBy, salesrep_value, bpartner_acqusitioncost, bpartner_actuallifetimevalue, bpartner_ad_language, BPartner_AD_OrgBP_ID, BPartner_AD_Org_ID, BPartner_BPartner_Parent_ID, BPartner_C_BP_Group_ID, BPartner_C_Dunning_ID, BPartner_C_Greeting_ID, BPartner_C_InvoiceSchedule_ID, BPartner_C_PaymentTerm_ID, bpartner_created, BPartner_CreatedBy, BPartner_C_TaxGroup_ID, bpartner_deliveryrule, bpartner_deliveryviarule, bpartner_description, bpartner_dunninggrace, bpartner_duns, bpartner_firstsale, bpartner_flatdiscount,
bpartner_freightcostrule, bpartner_invoicerule, bpartner_isactive, bpartner_iscustomer, bpartner_isdiscountprinted, bpartner_isemployee, bpartner_ismanufacturer, bpartner_isonetime, bpartner_ispotaxexempt, bpartner_isprospect, bpartner_issalesrep, bpartner_issummary, bpartner_istaxexempt, bpartner_isvendor, BPartner_Logo_ID, BPartner_M_DiscountSchema_ID, BPartner_M_PriceList_ID, bpartner_naics, bpartner_name2, bpartner_numberemployees, bpartner_paymentrule, bpartner_paymentrulepo, BPartner_PO_DiscountSchema_ID, BPartner_PO_PaymentTerm_ID, BPartner_PO_PriceList_ID, bpartner_poreference, bpartner_potentiallifetimeval, bpartner_rating, bpartner_referenceno, BPartner_SalesRep_ID, bpartner_salesvolume, bpartner_sendemail, bpartner_shareofcustomer, bpartner_shelflifeminpct, bpartner_so_creditlimit, bpartner_socreditstatus, bpartner_so_creditused, bpartner_so_description, bpartner_taxid, bpartner_totalopenbalance, bpartner_updated, BPartner_UpdatedBy, bpartner_url, BPartner_Value, CurSymbol, cur_description) AS SELECT i.ad_client_id AS AD_Client_ID, i.ad_org_id AS AD_Org_ID, i.isactive AS IsActive, i.created AS Created, i.createdby AS CreatedBy, i.updated AS Updated, i.updatedby AS UpdatedBy, CAST('en_US' AS CHARACTER VARYING(6)) AS AD_Language, i.c_invoice_id AS C_Invoice_ID, i.issotrx AS IsSOTrx, i.documentno AS DocumentNo, i.docstatus AS DocStatus, i.c_doctype_id AS C_DocType_ID, i.c_bpartner_id AS C_BPartner_ID, bp.value AS BPValue, bp.taxid AS BPTaxID, bp.naics AS NAICS, bp.duns AS DUNS, oi.c_location_id AS Org_Location_ID, oi.taxid AS TaxID, dt.printname AS DocumentType, dt.documentnote AS DocumentTypeNote, i.c_order_id AS C_Order_ID, i.salesrep_id AS SalesRep_ID, COALESCE(ubp.name, u.name) AS SalesRep_Name, i.dateinvoiced AS DateInvoiced, bpg.greeting AS BPGreeting, bp.name AS Name, bp.name2 AS Name2, bpcg.greeting AS BPContactGreeting, bpc.title AS Title, bpc.phone AS Phone, NULLIF(bpc.name, bp.name) AS ContactName, bpl.c_location_id AS C_Location_ID, bp.referenceno AS ReferenceNo, COALESCE(l.postal,'') || COALESCE(l.postal_add,'') AS Postal, i.description AS Description, i.poreference AS POReference, i.dateordered AS DateOrdered, i.c_currency_id AS C_Currency_ID, pt.name AS PaymentTerm, pt.documentnote AS PaymentTermNote, i.c_charge_id AS C_Charge_ID, i.chargeamt AS ChargeAmt, i.totallines AS TotalLines, i.grandtotal AS GrandTotal, i.grandtotal AS AmtInWords,
i.m_pricelist_id AS M_PriceList_ID, i.istaxincluded AS IsTaxIncluded, i.c_campaign_id AS C_Campaign_ID, i.c_project_id AS C_Project_ID, i.c_activity_id AS C_Activity_ID, i.ispaid AS IsPaid, COALESCE(oi.logo_id, ci.logo_id) AS Logo_ID, i.ad_orgtrx_id AS C_Invoice_AD_OrgTrx_ID, i.ad_user_id AS AD_User_ID, i.c_bpartner_location_id AS C_BPartner_Location_ID, i.c_conversiontype_id AS C_ConversionType_ID, i.c_doctypetarget_id AS C_DocTypeTarget_ID, i.c_dunninglevel_id AS C_DunningLevel_ID, i.c_payment_id AS C_Payment_ID, i.dateacct AS DateAcct, i.dateprinted AS DatePrinted, i.docaction AS DocAction, i.dunninggrace AS DunningGrace, i.generateto AS GenerateTo, i.invoicecollectiontype AS InvoiceCollectionType, i.isapproved AS IsApproved, i.isdiscountprinted AS IsDiscountPrinted, i.isindispute AS IsInDispute, i.ispayschedulevalid AS IsPayScheduleValid, i.isprinted AS IsPrinted, i.isselfservice AS c_invoice_isselfservice, i.istransferred AS IsTransferred, i.m_rma_id AS M_RMA_ID, i.paymentrule AS PaymentRule, i.posted AS Posted, i.processedon AS ProcessedOn, i.processing AS Processing, i.ref_invoice_id AS Ref_Invoice_ID, i.reversal_id AS Reversal_ID, i.sendemail AS SendEMail, i.user1_id AS User1_ID, i.user2_id AS User2_ID, pt.ad_org_id AS C_PaymentTerm_AD_Org_ID, pt.afterdelivery AS AfterDelivery, pt.c_paymentterm_id AS C_PaymentTerm_ID, pt.description AS c_paymentterm_description, pt.discount AS Discount, pt.discount2 AS Discount2, pt.discountdays AS DiscountDays, pt.discountdays2 AS DiscountDays2, pt.fixmonthcutoff AS FixMonthCutoff, pt.fixmonthday AS FixMonthDay, pt.fixmonthoffset AS FixMonthOffset, pt.gracedays AS GraceDays, pt.isactive AS c_paymentterm_isactive, pt.isdefault AS IsDefault, pt.isduefixed AS IsDueFixed, pt.isnextbusinessday AS IsNextBusinessDay, pt.isvalid AS IsValid, pt.netday AS NetDay, pt.netdays AS NetDays, pt.paymenttermusage AS PaymentTermUsage, pt.value AS c_paymentterm_value, bp.acqusitioncost AS bp_acqusitioncost, bp.actuallifetimevalue AS bp_actuallifetimevalue, bp.ad_language AS bp_ad_language, bp.ad_orgbp_id AS BP_AD_OrgBP_ID, bp.ad_org_id AS BP_AD_Org_ID, bp.bpartner_parent_id AS BP_BPartner_Parent_ID, bp.c_bp_group_id AS BP_C_BP_Group_ID, bp.c_dunning_id AS BP_C_Dunning_ID, bp.c_greeting_id AS BP_C_Greeting_ID, bp.c_invoiceschedule_id AS BP_C_InvoiceSchedule_ID, bp.c_paymentterm_id AS BP_C_PaymentTerm_ID, bp.created AS bp_created, bp.createdby AS BP_CreatedBy,
bp.c_taxgroup_id AS BP_C_TaxGroup_ID, bp.deliveryrule AS bp_deliveryrule, bp.deliveryviarule AS bp_deliveryviarule, bp.description AS bp_description, bp.dunninggrace AS bp_dunninggrace, bp.firstsale AS bp_firstsale, bp.flatdiscount AS bp_flatdiscount, bp.freightcostrule AS bp_freightcostrule, bp.invoicerule AS bp_invoicerule, bp.isactive AS bp_isactive, bp.iscustomer AS bp_iscustomer, bp.isdiscountprinted AS bp_isdiscountprinted, bp.isemployee AS bp_isemployee, bp.ismanufacturer AS bp_ismanufacturer, bp.isonetime AS bp_isonetime, bp.ispotaxexempt AS bp_ispotaxexempt, bp.isprospect AS bp_isprospect, bp.issalesrep AS bp_issalesrep, bp.issummary AS bp_issummary, bp.istaxexempt AS bp_istaxexempt, bp.isvendor AS bp_isvendor, bp.logo_id AS BP_Logo_ID, bp.m_discountschema_id AS BP_M_DiscountSchema_ID, bp.m_pricelist_id AS BP_M_PriceList_ID, bp.naics AS bp_naics, bp.numberemployees AS bp_numberemployees, bp.paymentrule AS bp_paymentrule, bp.paymentrulepo AS bp_paymentrulepo, bp.po_discountschema_id AS BP_PO_DiscountSchema_ID, bp.po_paymentterm_id AS BP_PO_PaymentTerm_ID, bp.po_pricelist_id AS BP_PO_PriceList_ID, bp.poreference AS bp_poreference, bp.potentiallifetimevalue AS bp_potentiallifetimevalue, bp.rating AS bp_rating, bp.salesrep_id AS BP_SalesRep_ID, bp.salesvolume AS bp_salesvolume, bp.sendemail AS bp_sendemail, bp.shareofcustomer AS bp_shareofcustomer, bp.shelflifeminpct AS bp_shelflifeminpct, bp.so_creditlimit AS bp_so_creditlimit, bp.socreditstatus AS bp_socreditstatus, bp.so_creditused AS bp_so_creditused, bp.so_description AS bp_so_description, bp.totalopenbalance AS bp_totalopenbalance, bp.updated AS bp_updated, bp.updatedby AS BP_UpdatedBy, bp.url AS bp_url, bpg.isactive AS c_greeting_isactive, bpg.isfirstnameonly AS IsFirstNameOnly, bpg.name AS c_greeting_name, bpl.ad_org_id AS BP_Location_AD_Org_ID, bpl.c_bpartner_id AS BP_Location_C_BPartner_ID, bpl.created AS bp_location_created, bpl.createdby AS BP_Location_CreatedBy, bpl.c_salesregion_id AS C_SalesRegion_ID, bpl.fax AS bp_location_fax, bpl.isactive AS bp_location_isactive, bpl.isbillto AS IsBillTo, bpl.isdn AS ISDN, bpl.ispayfrom AS IsPayFrom, bpl.isremitto AS IsRemitTo, bpl.isshipto AS IsShipTo, bpl.name AS bp_location_name, bpl.phone AS bp_location_phone, bpl.phone2 AS bp_location_phone2, bpl.updated AS bp_location_updated, bpl.updatedby AS BP_Location_UpdatedBy, l.address1 AS Address1, l.address2 AS Address2,
l.address3 AS Address3, l.address4 AS Address4, l.ad_org_id AS C_Location_AD_Org_ID, l.c_city_id AS C_City_ID, l.c_country_id AS C_Country_ID, l.city AS City, l.created AS c_location_created, l.createdby AS C_Location_CreatedBy, l.c_region_id AS C_Region_ID, l.isactive AS c_location_isactive, l.regionname AS RegionName, l.updated AS c_location_updated, l.updatedby AS C_Location_UpdatedBy, bpc.ad_org_id AS AD_User_AD_Org_ID, bpc.ad_orgtrx_id AS AD_User_AD_AD_OrgTrx_ID, bpc.birthday AS ad_user_ad_birthday, bpc.c_bpartner_id AS AD_User_C_BPartner_ID, bpc.c_bpartner_location_id AS AD_User_C_BPartner_Location_ID, bpc.c_greeting_id AS AD_User_C_Greeting_ID, bpc.comments AS ad_user_comments, bpc.created AS ad_user_created, bpc.createdby AS AD_User_CreatedBy, bpc.description AS ad_user_description, bpc.email AS ad_user_email, bpc.fax AS ad_user_fax, bpc.isactive AS ad_user_isactive, bpc.lastcontact AS ad_user_lastcontact, bpc.lastresult AS ad_user_lastresult, bpc.phone2 AS ad_user_phone2, bpc.supervisor_id AS AD_User_Supervisor_ID, bpc.updated AS ad_user_updated, bpc.updatedby AS AD_User_UpdatedBy, bpc.value AS ad_user_value, bpcg.isactive AS user_greeting_isactive, bpcg.isfirstnameonly AS user_greeting_isfirstnameonly, bpcg.name AS user_greeting_name, oi.ad_org_id AS AD_OrgInfo_AD_Org_ID, oi.ad_orgtype_id AS AD_OrgType_ID, oi.c_calendar_id AS C_Calendar_ID, oi.created AS ad_orginfo_created, oi.createdby AS AD_OrgInfo_CreatedBy, oi.dropship_warehouse_id AS DropShip_Warehouse_ID, oi.duns AS ad_orginfo_duns, oi.email AS ad_orginfo_email, oi.fax AS ad_orginfo_fax, oi.isactive AS ad_orginfo_isactive, oi.m_warehouse_id AS M_Warehouse_ID, oi.parent_org_id AS Parent_Org_ID, oi.phone AS ad_orginfo_phone, oi.phone2 AS ad_orginfo_phone2, oi.receiptfootermsg AS ReceiptFooterMsg, oi.supervisor_id AS Supervisor_ID, oi.updated AS ad_orginfo_updated, oi.updatedby AS AD_OrgInfo_UpdatedBy, u.ad_org_id AS SalesRep_AD_Org_ID, u.ad_orgtrx_id AS SalesRep_AD_AD_OrgTrx_ID, u.birthday AS salesrep_ad_birthday, u.c_bpartner_id AS SalesRep_C_BPartner_ID, u.c_bpartner_location_id AS SalesRep_C_BP_Location_ID, u.c_greeting_id AS SalesRep_C_Greeting_ID, u.comments AS salesrep_comments, u.created AS salesrep_created, u.createdby AS SalesRep_CreatedBy, u.description AS salesrep_description, u.email AS salesrep_email, u.fax AS salesrep_fax, u.isactive AS salesrep_isactive, u.lastcontact AS salesrep_lastcontact,
u.lastresult AS salesrep_lastresult, u.phone AS salesrep_phone, u.phone2 AS salesrep_phone2, u.supervisor_id AS SalesRep_Supervisor_ID, u.title AS salesrep_title, u.updated AS salesrep_updated, u.updatedby AS SalesRep_UpdatedBy, u.value AS salesrep_value, ubp.acqusitioncost AS bpartner_acqusitioncost, ubp.actuallifetimevalue AS bpartner_actuallifetimevalue, ubp.ad_language AS bpartner_ad_language, ubp.ad_orgbp_id AS BPartner_AD_OrgBP_ID, ubp.ad_org_id AS BPartner_AD_Org_ID, ubp.bpartner_parent_id AS BPartner_BPartner_Parent_ID, ubp.c_bp_group_id AS BPartner_C_BP_Group_ID, ubp.c_dunning_id AS BPartner_C_Dunning_ID, ubp.c_greeting_id AS BPartner_C_Greeting_ID, ubp.c_invoiceschedule_id AS BPartner_C_InvoiceSchedule_ID, ubp.c_paymentterm_id AS BPartner_C_PaymentTerm_ID, ubp.created AS bpartner_created, ubp.createdby AS BPartner_CreatedBy, ubp.c_taxgroup_id AS BPartner_C_TaxGroup_ID, ubp.deliveryrule AS bpartner_deliveryrule, ubp.deliveryviarule AS bpartner_deliveryviarule, ubp.description AS bpartner_description, ubp.dunninggrace AS bpartner_dunninggrace, ubp.duns AS bpartner_duns, ubp.firstsale AS bpartner_firstsale, ubp.flatdiscount AS bpartner_flatdiscount, ubp.freightcostrule AS bpartner_freightcostrule, ubp.invoicerule AS bpartner_invoicerule, ubp.isactive AS bpartner_isactive, ubp.iscustomer AS bpartner_iscustomer, ubp.isdiscountprinted AS bpartner_isdiscountprinted, ubp.isemployee AS bpartner_isemployee, ubp.ismanufacturer AS bpartner_ismanufacturer, ubp.isonetime AS bpartner_isonetime, ubp.ispotaxexempt AS bpartner_ispotaxexempt, ubp.isprospect AS bpartner_isprospect, ubp.issalesrep AS bpartner_issalesrep, ubp.issummary AS bpartner_issummary, ubp.istaxexempt AS bpartner_istaxexempt, ubp.isvendor AS bpartner_isvendor, ubp.logo_id AS BPartner_Logo_ID, ubp.m_discountschema_id AS BPartner_M_DiscountSchema_ID, ubp.m_pricelist_id AS BPartner_M_PriceList_ID, ubp.naics AS bpartner_naics, ubp.name2 AS bpartner_name2, ubp.numberemployees AS bpartner_numberemployees, ubp.paymentrule AS bpartner_paymentrule, ubp.paymentrulepo AS bpartner_paymentrulepo, ubp.po_discountschema_id AS BPartner_PO_DiscountSchema_ID, ubp.po_paymentterm_id AS BPartner_PO_PaymentTerm_ID, ubp.po_pricelist_id AS BPartner_PO_PriceList_ID, ubp.poreference AS bpartner_poreference, ubp.potentiallifetimevalue AS bpartner_potentiallifetimeval, ubp.rating AS bpartner_rating, ubp.referenceno AS bpartner_referenceno,
ubp.salesrep_id AS BPartner_SalesRep_ID, ubp.salesvolume AS bpartner_salesvolume, ubp.sendemail AS bpartner_sendemail, ubp.shareofcustomer AS bpartner_shareofcustomer, ubp.shelflifeminpct AS bpartner_shelflifeminpct, ubp.so_creditlimit AS bpartner_so_creditlimit, ubp.socreditstatus AS bpartner_socreditstatus, ubp.so_creditused AS bpartner_so_creditused, ubp.so_description AS bpartner_so_description, ubp.taxid AS bpartner_taxid, ubp.totalopenbalance AS bpartner_totalopenbalance, ubp.updated AS bpartner_updated, ubp.updatedby AS BPartner_UpdatedBy, ubp.url AS bpartner_url, ubp.value AS BPartner_Value, cur.cursymbol AS CurSymbol, cur.description AS cur_description FROM c_invoice i
JOIN c_doctype dt ON i.c_doctype_id = dt.c_doctype_id
JOIN c_paymentterm pt ON i.c_paymentterm_id = pt.c_paymentterm_id
JOIN c_bpartner bp ON i.c_bpartner_id = bp.c_bpartner_id
LEFT JOIN c_greeting bpg ON bp.c_greeting_id = bpg.c_greeting_id
JOIN c_bpartner_location bpl ON i.c_bpartner_location_id = bpl.c_bpartner_location_id
JOIN c_location l ON bpl.c_location_id = l.c_location_id
LEFT JOIN ad_user bpc ON i.ad_user_id = bpc.ad_user_id
LEFT JOIN c_greeting bpcg ON bpc.c_greeting_id = bpcg.c_greeting_id
JOIN ad_orginfo oi ON i.ad_org_id = oi.ad_org_id
JOIN ad_clientinfo ci ON i.ad_client_id = ci.ad_client_id
LEFT JOIN ad_user u ON i.salesrep_id = u.ad_user_id
LEFT JOIN c_bpartner ubp ON u.c_bpartner_id = ubp.c_bpartner_id
LEFT JOIN c_currency cur ON i.c_currency_id = cur.c_currency_id
;
-- Feb 15, 2022, 8:02:19 PM CET
UPDATE AD_ViewColumn SET ColumnSQL='COALESCE(l.postal,'''') || COALESCE(l.postal_add,'''')',Updated=TO_DATE('2022-02-15 20:02:19','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_ViewColumn_ID=201755
;
-- Feb 15, 2022, 8:02:30 PM CET
CREATE OR REPLACE VIEW C_Invoice_Header_vt(AD_Client_ID, AD_Org_ID, IsActive, Created, CreatedBy, Updated, UpdatedBy, AD_Language, C_Invoice_ID, IsSOTrx, DocumentNo, DocStatus, C_DocType_ID, C_BPartner_ID, BPValue, BPTaxID, NAICS, DUNS, Org_Location_ID, TaxID, DocumentType, DocumentTypeNote, C_Order_ID, SalesRep_ID, SalesRep_Name, DateInvoiced, BPGreeting, Name, Name2, BPContactGreeting, Title, Phone, ContactName, C_Location_ID, ReferenceNo, Postal, Description, POReference, DateOrdered, C_Currency_ID, PaymentTerm, PaymentTermNote, C_Charge_ID, ChargeAmt, TotalLines, GrandTotal, AmtInWords, M_PriceList_ID, IsTaxIncluded, C_Campaign_ID, C_Project_ID, C_Activity_ID, IsPaid, Logo_ID, C_Invoice_AD_OrgTrx_ID, AD_User_ID, C_BPartner_Location_ID, C_ConversionType_ID, C_DocTypeTarget_ID, C_DunningLevel_ID, C_Payment_ID, DateAcct, DatePrinted, DocAction, DunningGrace, GenerateTo, InvoiceCollectionType, IsApproved, IsDiscountPrinted, IsInDispute, IsPayScheduleValid, IsPrinted, c_invoice_isselfservice, IsTransferred, M_RMA_ID, PaymentRule, Posted, ProcessedOn, Processing, Ref_Invoice_ID, Reversal_ID, SendEMail, User1_ID, User2_ID, C_PaymentTerm_AD_Org_ID, AfterDelivery, C_PaymentTerm_ID, c_paymentterm_description, Discount, Discount2, DiscountDays, DiscountDays2, FixMonthCutoff, FixMonthDay, FixMonthOffset, GraceDays, c_paymentterm_isactive, IsDefault, IsDueFixed, IsNextBusinessDay, IsValid, NetDay, NetDays, PaymentTermUsage, c_paymentterm_value, bp_acqusitioncost, bp_actuallifetimevalue, bp_ad_language, BP_AD_OrgBP_ID, BP_AD_Org_ID, BP_BPartner_Parent_ID, BP_C_BP_Group_ID, BP_C_Dunning_ID, BP_C_Greeting_ID, BP_C_InvoiceSchedule_ID, BP_C_PaymentTerm_ID, bp_created, BP_CreatedBy, BP_C_TaxGroup_ID, bp_deliveryrule, bp_deliveryviarule, bp_description, bp_dunninggrace, bp_firstsale, bp_flatdiscount, bp_freightcostrule, bp_invoicerule, bp_isactive, bp_iscustomer, bp_isdiscountprinted, bp_isemployee, bp_ismanufacturer, bp_isonetime, bp_ispotaxexempt, bp_isprospect, bp_issalesrep, bp_issummary, bp_istaxexempt, bp_isvendor, BP_Logo_ID, BP_M_DiscountSchema_ID, BP_M_PriceList_ID, bp_naics, bp_numberemployees, bp_paymentrule, bp_paymentrulepo, BP_PO_DiscountSchema_ID, BP_PO_PaymentTerm_ID, BP_PO_PriceList_ID, bp_poreference, bp_potentiallifetimevalue, bp_rating, BP_SalesRep_ID, bp_salesvolume, bp_sendemail, bp_shareofcustomer, bp_shelflifeminpct, bp_so_creditlimit, bp_socreditstatus,
bp_so_creditused, bp_so_description, bp_totalopenbalance, bp_updated, BP_UpdatedBy, bp_url, c_greeting_isactive, IsFirstNameOnly, c_greeting_name, BP_Location_AD_Org_ID, BP_Location_C_BPartner_ID, bp_location_created, BP_Location_CreatedBy, C_SalesRegion_ID, bp_location_fax, bp_location_isactive, IsBillTo, ISDN, IsPayFrom, IsRemitTo, IsShipTo, bp_location_name, bp_location_phone, bp_location_phone2, bp_location_updated, BP_Location_UpdatedBy, Address1, Address2, Address3, Address4, C_Location_AD_Org_ID, C_City_ID, C_Country_ID, City, c_location_created, C_Location_CreatedBy, C_Region_ID, c_location_isactive, RegionName, c_location_updated, C_Location_UpdatedBy, AD_User_AD_Org_ID, AD_User_AD_AD_OrgTrx_ID, ad_user_ad_birthday, AD_User_C_BPartner_ID, AD_User_C_BPartner_Location_ID, AD_User_C_Greeting_ID, ad_user_comments, ad_user_created, AD_User_CreatedBy, ad_user_description, ad_user_email, ad_user_fax, ad_user_isactive, ad_user_lastcontact, ad_user_lastresult, ad_user_phone2, AD_User_Supervisor_ID, ad_user_updated, AD_User_UpdatedBy, ad_user_value, user_greeting_isactive, user_greeting_isfirstnameonly, user_greeting_name, AD_OrgInfo_AD_Org_ID, AD_OrgType_ID, C_Calendar_ID, ad_orginfo_created, AD_OrgInfo_CreatedBy, DropShip_Warehouse_ID, ad_orginfo_duns, ad_orginfo_email, ad_orginfo_fax, ad_orginfo_isactive, M_Warehouse_ID, Parent_Org_ID, ad_orginfo_phone, ad_orginfo_phone2, ReceiptFooterMsg, Supervisor_ID, ad_orginfo_updated, AD_OrgInfo_UpdatedBy, SalesRep_AD_Org_ID, SalesRep_AD_AD_OrgTrx_ID, salesrep_ad_birthday, SalesRep_C_BPartner_ID, SalesRep_C_BP_Location_ID, SalesRep_C_Greeting_ID, salesrep_comments, salesrep_created, SalesRep_CreatedBy, salesrep_description, salesrep_email, salesrep_fax, salesrep_isactive, salesrep_lastcontact, salesrep_lastresult, salesrep_phone, salesrep_phone2, SalesRep_Supervisor_ID, salesrep_title, salesrep_updated, SalesRep_UpdatedBy, salesrep_value, bpartner_acqusitioncost, bpartner_actuallifetimevalue, bpartner_ad_language, BPartner_AD_OrgBP_ID, BPartner_AD_Org_ID, BPartner_BPartner_Parent_ID, BPartner_C_BP_Group_ID, BPartner_C_Dunning_ID, BPartner_C_Greeting_ID, BPartner_C_InvoiceSchedule_ID, BPartner_C_PaymentTerm_ID, bpartner_created, BPartner_CreatedBy, BPartner_C_TaxGroup_ID, bpartner_deliveryrule, bpartner_deliveryviarule, bpartner_description, bpartner_dunninggrace, bpartner_duns, bpartner_firstsale, bpartner_flatdiscount,
bpartner_freightcostrule, bpartner_invoicerule, bpartner_isactive, bpartner_iscustomer, bpartner_isdiscountprinted, bpartner_isemployee, bpartner_ismanufacturer, bpartner_isonetime, bpartner_ispotaxexempt, bpartner_isprospect, bpartner_issalesrep, bpartner_issummary, bpartner_istaxexempt, bpartner_isvendor, BPartner_Logo_ID, BPartner_M_DiscountSchema_ID, BPartner_M_PriceList_ID, bpartner_naics, bpartner_name2, bpartner_numberemployees, bpartner_paymentrule, bpartner_paymentrulepo, BPartner_PO_DiscountSchema_ID, BPartner_PO_PaymentTerm_ID, BPartner_PO_PriceList_ID, bpartner_poreference, bpartner_potentiallifetimeval, bpartner_rating, bpartner_referenceno, BPartner_SalesRep_ID, bpartner_salesvolume, bpartner_sendemail, bpartner_shareofcustomer, bpartner_shelflifeminpct, bpartner_so_creditlimit, bpartner_socreditstatus, bpartner_so_creditused, bpartner_so_description, bpartner_taxid, bpartner_totalopenbalance, bpartner_updated, BPartner_UpdatedBy, bpartner_url, BPartner_Value, CurSymbol, cur_description) AS SELECT i.ad_client_id AS AD_Client_ID, i.ad_org_id AS AD_Org_ID, i.isactive AS IsActive, i.created AS Created, i.createdby AS CreatedBy, i.updated AS Updated, i.updatedby AS UpdatedBy, dt.ad_language AS AD_Language, i.c_invoice_id AS C_Invoice_ID, i.issotrx AS IsSOTrx, i.documentno AS DocumentNo, i.docstatus AS DocStatus, i.c_doctype_id AS C_DocType_ID, i.c_bpartner_id AS C_BPartner_ID, bp.value AS BPValue, bp.taxid AS BPTaxID, bp.naics AS NAICS, bp.duns AS DUNS, oi.c_location_id AS Org_Location_ID, oi.taxid AS TaxID, dt.printname AS DocumentType, dt.documentnote AS DocumentTypeNote, i.c_order_id AS C_Order_ID, i.salesrep_id AS SalesRep_ID, COALESCE(ubp.name, u.name) AS SalesRep_Name, i.dateinvoiced AS DateInvoiced, bpgt.greeting AS BPGreeting, bp.name AS Name, bp.name2 AS Name2, bpcgt.greeting AS BPContactGreeting, bpc.title AS Title, bpc.phone AS Phone, NULLIF(bpc.name, bp.name) AS ContactName, bpl.c_location_id AS C_Location_ID, bp.referenceno AS ReferenceNo, COALESCE(l.postal,'') || COALESCE(l.postal_add,'') AS Postal, i.description AS Description, i.poreference AS POReference, i.dateordered AS DateOrdered, i.c_currency_id AS C_Currency_ID, ptt.name AS PaymentTerm, ptt.documentnote AS PaymentTermNote, i.c_charge_id AS C_Charge_ID, i.chargeamt AS ChargeAmt, i.totallines AS TotalLines, i.grandtotal AS GrandTotal, i.grandtotal AS AmtInWords, i.m_pricelist_id AS M_PriceList_ID,
i.istaxincluded AS IsTaxIncluded, i.c_campaign_id AS C_Campaign_ID, i.c_project_id AS C_Project_ID, i.c_activity_id AS C_Activity_ID, i.ispaid AS IsPaid, COALESCE(oi.logo_id, ci.logo_id) AS Logo_ID, i.ad_orgtrx_id AS C_Invoice_AD_OrgTrx_ID, i.ad_user_id AS AD_User_ID, i.c_bpartner_location_id AS C_BPartner_Location_ID, i.c_conversiontype_id AS C_ConversionType_ID, i.c_doctypetarget_id AS C_DocTypeTarget_ID, i.c_dunninglevel_id AS C_DunningLevel_ID, i.c_payment_id AS C_Payment_ID, i.dateacct AS DateAcct, i.dateprinted AS DatePrinted, i.docaction AS DocAction, i.dunninggrace AS DunningGrace, i.generateto AS GenerateTo, i.invoicecollectiontype AS InvoiceCollectionType, i.isapproved AS IsApproved, i.isdiscountprinted AS IsDiscountPrinted, i.isindispute AS IsInDispute, i.ispayschedulevalid AS IsPayScheduleValid, i.isprinted AS IsPrinted, i.isselfservice AS c_invoice_isselfservice, i.istransferred AS IsTransferred, i.m_rma_id AS M_RMA_ID, i.paymentrule AS PaymentRule, i.posted AS Posted, i.processedon AS ProcessedOn, i.processing AS Processing, i.ref_invoice_id AS Ref_Invoice_ID, i.reversal_id AS Reversal_ID, i.sendemail AS SendEMail, i.user1_id AS User1_ID, i.user2_id AS User2_ID, ptt.ad_org_id AS C_PaymentTerm_AD_Org_ID, pt.afterdelivery AS AfterDelivery, pt.c_paymentterm_id AS C_PaymentTerm_ID, ptt.description AS c_paymentterm_description, pt.discount AS Discount, pt.discount2 AS Discount2, pt.discountdays AS DiscountDays, pt.discountdays2 AS DiscountDays2, pt.fixmonthcutoff AS FixMonthCutoff, pt.fixmonthday AS FixMonthDay, pt.fixmonthoffset AS FixMonthOffset, pt.gracedays AS GraceDays, ptt.isactive AS c_paymentterm_isactive, pt.isdefault AS IsDefault, pt.isduefixed AS IsDueFixed, pt.isnextbusinessday AS IsNextBusinessDay, pt.isvalid AS IsValid, pt.netday AS NetDay, pt.netdays AS NetDays, pt.paymenttermusage AS PaymentTermUsage, pt.value AS c_paymentterm_value, bp.acqusitioncost AS bp_acqusitioncost, bp.actuallifetimevalue AS bp_actuallifetimevalue, bp.ad_language AS bp_ad_language, bp.ad_orgbp_id AS BP_AD_OrgBP_ID, bp.ad_org_id AS BP_AD_Org_ID, bp.bpartner_parent_id AS BP_BPartner_Parent_ID, bp.c_bp_group_id AS BP_C_BP_Group_ID, bp.c_dunning_id AS BP_C_Dunning_ID, bp.c_greeting_id AS BP_C_Greeting_ID, bp.c_invoiceschedule_id AS BP_C_InvoiceSchedule_ID, bp.c_paymentterm_id AS BP_C_PaymentTerm_ID, bp.created AS bp_created, bp.createdby AS BP_CreatedBy, bp.c_taxgroup_id AS BP_C_TaxGroup_ID,
bp.deliveryrule AS bp_deliveryrule, bp.deliveryviarule AS bp_deliveryviarule, bp.description AS bp_description, bp.dunninggrace AS bp_dunninggrace, bp.firstsale AS bp_firstsale, bp.flatdiscount AS bp_flatdiscount, bp.freightcostrule AS bp_freightcostrule, bp.invoicerule AS bp_invoicerule, bp.isactive AS bp_isactive, bp.iscustomer AS bp_iscustomer, bp.isdiscountprinted AS bp_isdiscountprinted, bp.isemployee AS bp_isemployee, bp.ismanufacturer AS bp_ismanufacturer, bp.isonetime AS bp_isonetime, bp.ispotaxexempt AS bp_ispotaxexempt, bp.isprospect AS bp_isprospect, bp.issalesrep AS bp_issalesrep, bp.issummary AS bp_issummary, bp.istaxexempt AS bp_istaxexempt, bp.isvendor AS bp_isvendor, bp.logo_id AS BP_Logo_ID, bp.m_discountschema_id AS BP_M_DiscountSchema_ID, bp.m_pricelist_id AS BP_M_PriceList_ID, bp.naics AS bp_naics, bp.numberemployees AS bp_numberemployees, bp.paymentrule AS bp_paymentrule, bp.paymentrulepo AS bp_paymentrulepo, bp.po_discountschema_id AS BP_PO_DiscountSchema_ID, bp.po_paymentterm_id AS BP_PO_PaymentTerm_ID, bp.po_pricelist_id AS BP_PO_PriceList_ID, bp.poreference AS bp_poreference, bp.potentiallifetimevalue AS bp_potentiallifetimevalue, bp.rating AS bp_rating, bp.salesrep_id AS BP_SalesRep_ID, bp.salesvolume AS bp_salesvolume, bp.sendemail AS bp_sendemail, bp.shareofcustomer AS bp_shareofcustomer, bp.shelflifeminpct AS bp_shelflifeminpct, bp.so_creditlimit AS bp_so_creditlimit, bp.socreditstatus AS bp_socreditstatus, bp.so_creditused AS bp_so_creditused, bp.so_description AS bp_so_description, bp.totalopenbalance AS bp_totalopenbalance, bp.updated AS bp_updated, bp.updatedby AS BP_UpdatedBy, bp.url AS bp_url, bpgt.isactive AS c_greeting_isactive, bpg.isfirstnameonly AS IsFirstNameOnly, bpgt.name AS c_greeting_name, bpl.ad_org_id AS BP_Location_AD_Org_ID, bpl.c_bpartner_id AS BP_Location_C_BPartner_ID, bpl.created AS bp_location_created, bpl.createdby AS BP_Location_CreatedBy, bpl.c_salesregion_id AS C_SalesRegion_ID, bpl.fax AS bp_location_fax, bpl.isactive AS bp_location_isactive, bpl.isbillto AS IsBillTo, bpl.isdn AS ISDN, bpl.ispayfrom AS IsPayFrom, bpl.isremitto AS IsRemitTo, bpl.isshipto AS IsShipTo, bpl.name AS bp_location_name, bpl.phone AS bp_location_phone, bpl.phone2 AS bp_location_phone2, bpl.updated AS bp_location_updated, bpl.updatedby AS BP_Location_UpdatedBy, l.address1 AS Address1, l.address2 AS Address2, l.address3 AS Address3,
l.address4 AS Address4, l.ad_org_id AS C_Location_AD_Org_ID, l.c_city_id AS C_City_ID, l.c_country_id AS C_Country_ID, l.city AS City, l.created AS c_location_created, l.createdby AS C_Location_CreatedBy, l.c_region_id AS C_Region_ID, l.isactive AS c_location_isactive, l.regionname AS RegionName, l.updated AS c_location_updated, l.updatedby AS C_Location_UpdatedBy, bpc.ad_org_id AS AD_User_AD_Org_ID, bpc.ad_orgtrx_id AS AD_User_AD_AD_OrgTrx_ID, bpc.birthday AS ad_user_ad_birthday, bpc.c_bpartner_id AS AD_User_C_BPartner_ID, bpc.c_bpartner_location_id AS AD_User_C_BPartner_Location_ID, bpc.c_greeting_id AS AD_User_C_Greeting_ID, bpc.comments AS ad_user_comments, bpc.created AS ad_user_created, bpc.createdby AS AD_User_CreatedBy, bpc.description AS ad_user_description, bpc.email AS ad_user_email, bpc.fax AS ad_user_fax, bpc.isactive AS ad_user_isactive, bpc.lastcontact AS ad_user_lastcontact, bpc.lastresult AS ad_user_lastresult, bpc.phone2 AS ad_user_phone2, bpc.supervisor_id AS AD_User_Supervisor_ID, bpc.updated AS ad_user_updated, bpc.updatedby AS AD_User_UpdatedBy, bpc.value AS ad_user_value, bpcgt.isactive AS user_greeting_isactive, bpcg.isfirstnameonly AS user_greeting_isfirstnameonly, bpcgt.name AS user_greeting_name, oi.ad_org_id AS AD_OrgInfo_AD_Org_ID, oi.ad_orgtype_id AS AD_OrgType_ID, oi.c_calendar_id AS C_Calendar_ID, oi.created AS ad_orginfo_created, oi.createdby AS AD_OrgInfo_CreatedBy, oi.dropship_warehouse_id AS DropShip_Warehouse_ID, oi.duns AS ad_orginfo_duns, oi.email AS ad_orginfo_email, oi.fax AS ad_orginfo_fax, oi.isactive AS ad_orginfo_isactive, oi.m_warehouse_id AS M_Warehouse_ID, oi.parent_org_id AS Parent_Org_ID, oi.phone AS ad_orginfo_phone, oi.phone2 AS ad_orginfo_phone2, oi.receiptfootermsg AS ReceiptFooterMsg, oi.supervisor_id AS Supervisor_ID, oi.updated AS ad_orginfo_updated, oi.updatedby AS AD_OrgInfo_UpdatedBy, u.ad_org_id AS SalesRep_AD_Org_ID, u.ad_orgtrx_id AS SalesRep_AD_AD_OrgTrx_ID, u.birthday AS salesrep_ad_birthday, u.c_bpartner_id AS SalesRep_C_BPartner_ID, u.c_bpartner_location_id AS SalesRep_C_BP_Location_ID, u.c_greeting_id AS SalesRep_C_Greeting_ID, u.comments AS salesrep_comments, u.created AS salesrep_created, u.createdby AS SalesRep_CreatedBy, u.description AS salesrep_description, u.email AS salesrep_email, u.fax AS salesrep_fax, u.isactive AS salesrep_isactive, u.lastcontact AS salesrep_lastcontact, u.lastresult AS salesrep_lastresult,
u.phone AS salesrep_phone, u.phone2 AS salesrep_phone2, u.supervisor_id AS SalesRep_Supervisor_ID, u.title AS salesrep_title, u.updated AS salesrep_updated, u.updatedby AS SalesRep_UpdatedBy, u.value AS salesrep_value, ubp.acqusitioncost AS bpartner_acqusitioncost, ubp.actuallifetimevalue AS bpartner_actuallifetimevalue, ubp.ad_language AS bpartner_ad_language, ubp.ad_orgbp_id AS BPartner_AD_OrgBP_ID, ubp.ad_org_id AS BPartner_AD_Org_ID, ubp.bpartner_parent_id AS BPartner_BPartner_Parent_ID, ubp.c_bp_group_id AS BPartner_C_BP_Group_ID, ubp.c_dunning_id AS BPartner_C_Dunning_ID, ubp.c_greeting_id AS BPartner_C_Greeting_ID, ubp.c_invoiceschedule_id AS BPartner_C_InvoiceSchedule_ID, ubp.c_paymentterm_id AS BPartner_C_PaymentTerm_ID, ubp.created AS bpartner_created, ubp.createdby AS BPartner_CreatedBy, ubp.c_taxgroup_id AS BPartner_C_TaxGroup_ID, ubp.deliveryrule AS bpartner_deliveryrule, ubp.deliveryviarule AS bpartner_deliveryviarule, ubp.description AS bpartner_description, ubp.dunninggrace AS bpartner_dunninggrace, ubp.duns AS bpartner_duns, ubp.firstsale AS bpartner_firstsale, ubp.flatdiscount AS bpartner_flatdiscount, ubp.freightcostrule AS bpartner_freightcostrule, ubp.invoicerule AS bpartner_invoicerule, ubp.isactive AS bpartner_isactive, ubp.iscustomer AS bpartner_iscustomer, ubp.isdiscountprinted AS bpartner_isdiscountprinted, ubp.isemployee AS bpartner_isemployee, ubp.ismanufacturer AS bpartner_ismanufacturer, ubp.isonetime AS bpartner_isonetime, ubp.ispotaxexempt AS bpartner_ispotaxexempt, ubp.isprospect AS bpartner_isprospect, ubp.issalesrep AS bpartner_issalesrep, ubp.issummary AS bpartner_issummary, ubp.istaxexempt AS bpartner_istaxexempt, ubp.isvendor AS bpartner_isvendor, ubp.logo_id AS BPartner_Logo_ID, ubp.m_discountschema_id AS BPartner_M_DiscountSchema_ID, ubp.m_pricelist_id AS BPartner_M_PriceList_ID, ubp.naics AS bpartner_naics, ubp.name2 AS bpartner_name2, ubp.numberemployees AS bpartner_numberemployees, ubp.paymentrule AS bpartner_paymentrule, ubp.paymentrulepo AS bpartner_paymentrulepo, ubp.po_discountschema_id AS BPartner_PO_DiscountSchema_ID, ubp.po_paymentterm_id AS BPartner_PO_PaymentTerm_ID, ubp.po_pricelist_id AS BPartner_PO_PriceList_ID, ubp.poreference AS bpartner_poreference, ubp.potentiallifetimevalue AS bpartner_potentiallifetimeval, ubp.rating AS bpartner_rating, ubp.referenceno AS bpartner_referenceno, ubp.salesrep_id AS BPartner_SalesRep_ID,
ubp.salesvolume AS bpartner_salesvolume, ubp.sendemail AS bpartner_sendemail, ubp.shareofcustomer AS bpartner_shareofcustomer, ubp.shelflifeminpct AS bpartner_shelflifeminpct, ubp.so_creditlimit AS bpartner_so_creditlimit, ubp.socreditstatus AS bpartner_socreditstatus, ubp.so_creditused AS bpartner_so_creditused, ubp.so_description AS bpartner_so_description, ubp.taxid AS bpartner_taxid, ubp.totalopenbalance AS bpartner_totalopenbalance, ubp.updated AS bpartner_updated, ubp.updatedby AS BPartner_UpdatedBy, ubp.url AS bpartner_url, ubp.value AS BPartner_Value, cur.cursymbol AS CurSymbol, cur.description AS cur_description FROM c_invoice i
JOIN c_doctype_trl dt ON i.c_doctype_id = dt.c_doctype_id
JOIN c_paymentterm pt ON i.c_paymentterm_id = pt.c_paymentterm_id
JOIN c_paymentterm_trl ptt ON i.c_paymentterm_id = ptt.c_paymentterm_id AND dt.ad_language = ptt.ad_language
JOIN c_bpartner bp ON i.c_bpartner_id = bp.c_bpartner_id
LEFT JOIN c_greeting bpg ON bp.c_greeting_id = bpg.c_greeting_id
LEFT JOIN c_greeting_trl bpgt ON bp.c_greeting_id = bpgt.c_greeting_id AND dt.ad_language = bpgt.ad_language
JOIN c_bpartner_location bpl ON i.c_bpartner_location_id = bpl.c_bpartner_location_id
JOIN c_location l ON bpl.c_location_id = l.c_location_id
LEFT JOIN ad_user bpc ON i.ad_user_id = bpc.ad_user_id
LEFT JOIN c_greeting bpcg ON bpc.c_greeting_id = bpcg.c_greeting_id
LEFT JOIN c_greeting_trl bpcgt ON bpc.c_greeting_id = bpcgt.c_greeting_id AND dt.ad_language = bpcgt.ad_language
JOIN ad_orginfo oi ON i.ad_org_id = oi.ad_org_id
JOIN ad_clientinfo ci ON i.ad_client_id = ci.ad_client_id
LEFT JOIN ad_user u ON i.salesrep_id = u.ad_user_id
LEFT JOIN c_bpartner ubp ON u.c_bpartner_id = ubp.c_bpartner_id
LEFT JOIN c_currency_trl cur ON i.c_currency_id = cur.c_currency_id AND dt.ad_language = cur.ad_language
;
-- Feb 15, 2022, 8:04:46 PM CET
UPDATE AD_ViewColumn SET ColumnSQL='COALESCE(l.postal,'''') || COALESCE(l.postal_add,'''')',Updated=TO_DATE('2022-02-15 20:04:46','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_ViewColumn_ID=204722
;
-- Feb 15, 2022, 8:04:56 PM CET
CREATE OR REPLACE VIEW C_Order_Header_v(AD_Client_ID, AD_Org_ID, IsActive, Created, CreatedBy, Updated, UpdatedBy, AD_Language, C_Order_ID, IsSOTrx, DocumentNo, DocStatus, C_DocType_ID, C_BPartner_ID, BPValue, BPTaxID, NAICS, DUNS, Org_Location_ID, TaxID, M_Warehouse_ID, Warehouse_Location_ID, DocumentType, DocumentTypeNote, SalesRep_ID, SalesRep_Name, DateOrdered, DatePromised, BPGreeting, Name, Name2, BPContactGreeting, Title, Phone, ContactName, C_Location_ID, Postal, ReferenceNo, Bill_BPartner_ID, Bill_Location_ID, Bill_User_ID, Bill_BPValue, Bill_BPTaxID, Bill_Name, Bill_Name2, Bill_Title, Bill_Phone, Bill_ContactName, Bill_C_Location_ID, Description, POReference, C_Currency_ID, PaymentTerm, PaymentTermNote, C_Charge_ID, ChargeAmt, TotalLines, GrandTotal, AmtInWords, M_PriceList_ID, IsTaxIncluded, Volume, Weight, C_Campaign_ID, C_Project_ID, C_Activity_ID, M_Shipper_ID, DeliveryRule, DeliveryViaRule, PriorityRule, InvoiceRule, Logo_ID, AD_OrgTrx_ID, AD_User_ID, AmountRefunded, AmountTendered, C_BPartner_Location_ID, C_CashLine_ID, C_CashPlanLine_ID, C_ConversionType_ID, C_DocTypeTarget_ID, CopyFrom, C_Payment_ID, C_PaymentTerm_ID, C_POS_ID, DateAcct, DatePrinted, DocAction, DropShip_BPartner_ID, DropShip_Location_ID, DropShip_User_ID, FreightAmt, FreightCostRule, IsApproved, IsCreditApproved, IsDelivered, IsDiscountPrinted, IsDropShip, IsInvoiced, IsPayScheduleValid, IsPrinted, IsSelected, IsSelfService, IsTransferred, Link_Order_ID, M_FreightCategory_ID, OrderType, Pay_BPartner_ID, Pay_Location_ID, PaymentRule, Posted, Processed, ProcessedOn, PromotionCode, Ref_Order_ID, SendEMail, User1_ID, User2_ID, M_Warehouse_AD_Org_ID, m_warehouse_description, m_warehouse_isactive, IsDisallowNegativeInv, IsInTransit, M_WarehouseSource_ID, m_warehouse_name, ReplenishmentClass, Separator, m_warehouse_value, C_PaymentTerm_AD_Org_ID, AfterDelivery, c_paymentterm_description, Discount, Discount2, DiscountDays, DiscountDays2, FixMonthCutoff, FixMonthDay, FixMonthOffset, GraceDays, c_paymentterm_isactive, IsDefault, IsDueFixed, IsNextBusinessDay, IsValid, NetDay, NetDays, PaymentTermUsage, m_paymentterm_value, bp_acqusitioncost, bp_actuallifetimevalue, bp_ad_language, BP_AD_OrgBP_ID, BP_AD_Org_ID, BP_BPartner_Parent_ID, BP_C_BP_Group_ID, BP_C_Dunning_ID, BP_C_Greeting_ID, BP_C_InvoiceSchedule_ID, BP_C_PaymentTerm_ID, bp_created, BP_CreatedBy, BP_C_TaxGroup_ID, bp_deliveryrule,
bp_deliveryviarule, bp_description, bp_dunninggrace, bp_firstsale, bp_flatdiscount, bp_freightcostrule, bp_invoicerule, bp_isactive, bp_iscustomer, bp_isdiscountprinted, bp_isemployee, bp_ismanufacturer, bp_isonetime, bp_ispotaxexempt, bp_isprospect, bp_issalesrep, bp_issummary, bp_istaxexempt, bp_isvendor, BP_Logo_ID, BP_M_DiscountSchema_ID, BP_M_PriceList_ID, bp_numberemployees, bp_paymentrule, bp_paymentrulepo, BP_PO_DiscountSchema_ID, BP_PO_PaymentTerm_ID, BP_PO_PriceList_ID, bp_poreference, bp_potentiallifetimevalue, bp_rating, BP_SalesRep_ID, bp_salesvolume, bp_sendemail, bp_shareofcustomer, bp_shelflifeminpct, bp_so_creditlimit, bp_socreditstatus, bp_so_creditused, bp_so_description, bp_totalopenbalance, bp_updated, BP_UpdatedBy, bp_url, C_Greeting_AD_Org_ID, c_greeting_isactive, IsFirstNameOnly, c_greeting_name, BP_Location_AD_Org_ID, BP_Location_C_BPartner_ID, bp_location_created, BP_Location_CreatedBy, BP_Location_C_SalesRegion_ID, bp_location_fax, bp_location_isactive, bp_location_isbillto, bp_location_isdn, bp_location_ispayfrom, bp_location_isremitto, bp_location_isshipto, bp_location_name, bp_location_phone, bp_location_phone2, bp_location_updated, BP_Location_UpdatedBy, Address1, Address2, Address3, Address4, C_Location_AD_Org_ID, C_City_ID, C_Country_ID, City, c_location_created, C_Location_CreatedBy, C_Region_ID, c_location_isactive, RegionName, c_location_updated, C_Location_UpdatedBy, AD_User_AD_Org_ID, AD_User_AD_OrgTrx_ID, ad_user_ad_birthday, AD_User_C_BPartner_ID, AD_User_C_BPartner_Location_ID, AD_User_C_Greeting_ID, ad_user_comments, ad_user_created, AD_User_CreatedBy, ad_user_description, ad_user_email, ad_user_fax, ad_user_isactive, ad_user_lastcontact, ad_user_lastresult, ad_user_phone2, AD_User_Supervisor_ID, ad_user_updated, AD_User_UpdatedBy, ad_user_value, C_User_Greeting_AD_Org_ID, c_user_greeting_isactive, c_user_greeting_isfnameonly, c_user_greeting_name, AD_OrgInfo_AD_Org_ID, AD_OrgType_ID, C_Calendar_ID, ad_orginfo_created, AD_OrgInfo_CreatedBy, DropShip_Warehouse_ID, ad_orginfo_duns, ad_orginfo_email, ad_orginfo_fax, ad_orginfo_isactive, AD_OrgInfo_M_Warehouse_ID, Parent_Org_ID, ad_orginfo_phone, ad_orginfo_phone2, ReceiptFooterMsg, Supervisor_ID, ad_orginfo_updated, AD_OrgInfo_UpdatedBy, SalesRep_AD_Org_ID, SalesRep_AD_OrgTrx_ID, salesrep_ad_birthday, SalesRep_C_BPartner_ID, SalesRep_C_BP_Location_ID, SalesRep_C_Greeting_ID,
salesrep_comments, salesrep_created, SalesRep_CreatedBy, salesrep_description, salesrep_email, salesrep_fax, salesrep_isactive, salesrep_lastcontact, salesrep_lastresult, salesrep_phone, salesrep_phone2, SalesRep_Supervisor_ID, salesrep_title, salesrep_updated, SalesRep_UpdatedBy, salesrep_value, salesrep_bp_acqusitioncost, salesrep_bp_actuallifetimeval, salesrep_bp_ad_language, SalesRep_BP_AD_OrgBP_ID, SalesRep_BP_AD_Org_ID, SalesRep_BP_BPartner_Parent_ID, SalesRep_BP_C_BP_Group_ID, SalesRep_BP_C_Dunning_ID, SalesRep_BP_C_Greeting_ID, SalesRep_BP_C_InvoiceSched_ID, SalesRep_BP_C_PaymentTerm_ID, salesrep_bp_created, SalesRep_BP_CreatedBy, SalesRep_BP_C_TaxGroup_ID, salesrep_bp_deliveryrule, salesrep_bp_deliveryviarule, salesrep_bp_description, salesrep_bp_dunninggrace, salesrep_bp_duns, salesrep_bp_firstsale, salesrep_bp_flatdiscount, salesrep_bp_freightcostrule, salesrep_bp_invoicerule, salesrep_bp_isactive, salesrep_bp_iscustomer, salesrep_bp_isdiscountprinted, salesrep_bp_isemployee, salesrep_bp_ismanufacturer, salesrep_bp_isonetime, salesrep_bp_ispotaxexempt, salesrep_bp_isprospect, salesrep_bp_issalesrep, salesrep_bp_issummary, salesrep_bp_istaxexempt, salesrep_bp_isvendor, SalesRep_BP_Logo_ID, SalesRep_BP_M_DiscountSchm_ID, SalesRep_BP_M_PriceList_ID, salesrep_bp_naics, salesrep_bp_name2, salesrep_bp_numberemployees, salesrep_bp_paymentrule, salesrep_bp_paymentrulepo, SalesRep_BP_PO_DiscountSchm_ID, SalesRep_BP_PO_PaymentTerm_ID, SalesRep_BP_PO_PriceList_ID, salesrep_bp_poreference, salesrep_bp_potentiallifetime, salesrep_bp_rating, salesrep_bp_referenceno, SalesRep_BP_SalesRep_ID, salesrep_bp_salesvolume, salesrep_bp_sendemail, salesrep_bp_shareofcustomer, salesrep_bp_shelflifeminpct, salesrep_bp_so_creditlimit, salesrep_bp_socreditstatus, salesrep_bp_so_creditused, salesrep_bp_so_description, salesrep_bp_taxid, salesrep_bp_totalopenbalance, salesrep_bp_updated, SalesRep_BP_UpdatedBy, salesrep_bp_url, salesrep_bp_value, bill_bp_acqusitioncost, bill_bp_actuallifetimevalue, bill_bp_ad_language, Bill_BP_AD_OrgBP_ID, Bill_BP_AD_Org_ID, Bill_BP_BPartner_Parent_ID, Bill_BP_C_BP_Group_ID, Bill_BP_C_Dunning_ID, Bill_BP_C_Greeting_ID, Bill_BP_C_InvoiceSchedule_ID, Bill_BP_C_PaymentTerm_ID, bill_bp_created, Bill_BP_CreatedBy, Bill_BP_C_TaxGroup_ID, bill_bp_deliveryrule, bill_bp_deliveryviarule, bill_bp_description, bill_bp_dunninggrace, bill_bp_duns, bill_bp_firstsale,
bill_bp_flatdiscount, bill_bp_freightcostrule, bill_bp_invoicerule, bill_bp_isactive, bill_bp_iscustomer, bill_bp_isdiscountprinted, bill_bp_isemployee, bill_bp_ismanufacturer, bill_bp_isonetime, bill_bp_ispotaxexempt, bill_bp_isprospect, bill_bp_issalesrep, bill_bp_issummary, bill_bp_istaxexempt, bill_bp_isvendor, Bill_BP_Logo_ID, Bill_BP_M_DiscountSchema_ID, Bill_BP_M_PriceList_ID, bill_bp_naics, bill_bp_numberemployees, bill_bp_paymentrule, bill_bp_paymentrulepo, Bill_BP_PO_DiscountSchema_ID, Bill_BP_PO_PaymentTerm_ID, Bill_BP_PO_PriceList_ID, bill_bp_poreference, bill_bp_potentiallifetimevalue, bill_bp_rating, bill_bp_referenceno, Bill_BP_SalesRep_ID, bill_bp_salesvolume, bill_bp_sendemail, bill_bp_shareofcustomer, bill_bp_shelflifeminpct, bill_bp_so_creditlimit, bill_bp_socreditstatus, bill_bp_so_creditused, bill_bp_so_description, bill_bp_totalopenbalance, bill_bp_updated, Bill_BP_UpdatedBy, bill_bp_url, Bill_BP_Location_AD_Org_ID, Bill_BP_Location_C_BPartner_ID, bill_bp_location_created, Bill_BP_Location_CreatedBy, Bill_BP_Location_C_SalesReg_ID, bill_bp_location_fax, bill_bp_location_isactive, bill_bp_location_isbillto, bill_bp_location_isdn, bill_bp_location_ispayfrom, bill_bp_location_isremitto, bill_bp_location_isshipto, bill_bp_location_name, bill_bp_location_phone, bill_bp_location_phone2, bill_bp_location_updated, Bill_BP_Location_UpdatedBy, Bill_User_AD_Org_ID, Bill_User_AD_OrgTrx_ID, bill_user_ad_birthday, Bill_User_C_BPartner_ID, Bill_User_C_BP_Location_ID, Bill_User_C_Greeting_ID, bill_user_comments, bill_user_created, Bill_User_CreatedBy, bill_user_description, bill_user_email, bill_user_fax, bill_user_isactive, bill_user_lastcontact, bill_user_lastresult, bill_user_phone2, Bill_User_Supervisor_ID, bill_user_updated, Bill_User_UpdatedBy, bill_user_value, CurSymbol, cur_description) AS SELECT o.ad_client_id AS AD_Client_ID, o.ad_org_id AS AD_Org_ID, o.isactive AS IsActive, o.created AS Created, o.createdby AS CreatedBy, o.updated AS Updated, o.updatedby AS UpdatedBy, CAST('en_US' AS CHARACTER VARYING(6)) AS AD_Language, o.c_order_id AS C_Order_ID, o.issotrx AS IsSOTrx, o.documentno AS DocumentNo, o.docstatus AS DocStatus, o.c_doctype_id AS C_DocType_ID, o.c_bpartner_id AS C_BPartner_ID, bp.value AS BPValue, bp.taxid AS BPTaxID, bp.naics AS NAICS, bp.duns AS DUNS, oi.c_location_id AS Org_Location_ID, oi.taxid AS TaxID, o.m_warehouse_id AS M_Warehouse_ID,
wh.c_location_id AS Warehouse_Location_ID, dt.printname AS DocumentType, dt.documentnote AS DocumentTypeNote, o.salesrep_id AS SalesRep_ID, COALESCE(ubp.name, u.name) AS SalesRep_Name, o.dateordered AS DateOrdered, o.datepromised AS DatePromised, bpg.greeting AS BPGreeting, bp.name AS Name, bp.name2 AS Name2, bpcg.greeting AS BPContactGreeting, bpc.title AS Title, bpc.phone AS Phone, NULLIF(bpc.name, bp.name) AS ContactName, bpl.c_location_id AS C_Location_ID, COALESCE(l.postal,'') || COALESCE(l.postal_add,'') AS Postal, bp.referenceno AS ReferenceNo, o.bill_bpartner_id AS Bill_BPartner_ID, o.bill_location_id AS Bill_Location_ID, o.bill_user_id AS Bill_User_ID, bbp.value AS Bill_BPValue, bbp.taxid AS Bill_BPTaxID, bbp.name AS Bill_Name, bbp.name2 AS Bill_Name2, bbpc.title AS Bill_Title, bbpc.phone AS Bill_Phone, NULLIF(bbpc.name, bbp.name) AS Bill_ContactName, bbpl.c_location_id AS Bill_C_Location_ID, o.description AS Description, o.poreference AS POReference, o.c_currency_id AS C_Currency_ID, pt.name AS PaymentTerm, pt.documentnote AS PaymentTermNote, o.c_charge_id AS C_Charge_ID, o.chargeamt AS ChargeAmt, o.totallines AS TotalLines, o.grandtotal AS GrandTotal, o.grandtotal AS AmtInWords, o.m_pricelist_id AS M_PriceList_ID, o.istaxincluded AS IsTaxIncluded, o.volume AS Volume, o.weight AS Weight, o.c_campaign_id AS C_Campaign_ID, o.c_project_id AS C_Project_ID, o.c_activity_id AS C_Activity_ID, o.m_shipper_id AS M_Shipper_ID, o.deliveryrule AS DeliveryRule, o.deliveryviarule AS DeliveryViaRule, o.priorityrule AS PriorityRule, o.invoicerule AS InvoiceRule, COALESCE(oi.logo_id, ci.logo_id) AS Logo_ID, o.ad_orgtrx_id AS AD_OrgTrx_ID, o.ad_user_id AS AD_User_ID, o.amountrefunded AS AmountRefunded, o.amounttendered AS AmountTendered, o.c_bpartner_location_id AS C_BPartner_Location_ID, o.c_cashline_id AS C_CashLine_ID, o.c_cashplanline_id AS C_CashPlanLine_ID, o.c_conversiontype_id AS C_ConversionType_ID, o.c_doctypetarget_id AS C_DocTypeTarget_ID, o.copyfrom AS CopyFrom, o.c_payment_id AS C_Payment_ID, o.c_paymentterm_id AS C_PaymentTerm_ID, o.c_pos_id AS C_POS_ID, o.dateacct AS DateAcct, o.dateprinted AS DatePrinted, o.docaction AS DocAction, o.dropship_bpartner_id AS DropShip_BPartner_ID, o.dropship_location_id AS DropShip_Location_ID, o.dropship_user_id AS DropShip_User_ID, o.freightamt AS FreightAmt, o.freightcostrule AS FreightCostRule, o.isapproved AS IsApproved,
o.iscreditapproved AS IsCreditApproved, o.isdelivered AS IsDelivered, o.isdiscountprinted AS IsDiscountPrinted, o.isdropship AS IsDropShip, o.isinvoiced AS IsInvoiced, o.ispayschedulevalid AS IsPayScheduleValid, o.isprinted AS IsPrinted, o.isselected AS IsSelected, o.isselfservice AS IsSelfService, o.istransferred AS IsTransferred, o.link_order_id AS Link_Order_ID, o.m_freightcategory_id AS M_FreightCategory_ID, o.ordertype AS OrderType, o.pay_bpartner_id AS Pay_BPartner_ID, o.pay_location_id AS Pay_Location_ID, o.paymentrule AS PaymentRule, o.posted AS Posted, o.processed AS Processed, o.processedon AS ProcessedOn, o.promotioncode AS PromotionCode, o.ref_order_id AS Ref_Order_ID, o.sendemail AS SendEMail, o.user1_id AS User1_ID, o.user2_id AS User2_ID, wh.ad_org_id AS M_Warehouse_AD_Org_ID, wh.description AS m_warehouse_description, wh.isactive AS m_warehouse_isactive, wh.isdisallownegativeinv AS IsDisallowNegativeInv, wh.isintransit AS IsInTransit, wh.m_warehousesource_id AS M_WarehouseSource_ID, wh.name AS m_warehouse_name, wh.replenishmentclass AS ReplenishmentClass, wh.separator AS Separator, wh.value AS m_warehouse_value, pt.ad_org_id AS C_PaymentTerm_AD_Org_ID, pt.afterdelivery AS AfterDelivery, pt.description AS c_paymentterm_description, pt.discount AS Discount, pt.discount2 AS Discount2, pt.discountdays AS DiscountDays, pt.discountdays2 AS DiscountDays2, pt.fixmonthcutoff AS FixMonthCutoff, pt.fixmonthday AS FixMonthDay, pt.fixmonthoffset AS FixMonthOffset, pt.gracedays AS GraceDays, pt.isactive AS c_paymentterm_isactive, pt.isdefault AS IsDefault, pt.isduefixed AS IsDueFixed, pt.isnextbusinessday AS IsNextBusinessDay, pt.isvalid AS IsValid, pt.netday AS NetDay, pt.netdays AS NetDays, pt.paymenttermusage AS PaymentTermUsage, pt.value AS m_paymentterm_value, bp.acqusitioncost AS bp_acqusitioncost, bp.actuallifetimevalue AS bp_actuallifetimevalue, bp.ad_language AS bp_ad_language, bp.ad_orgbp_id AS BP_AD_OrgBP_ID, bp.ad_org_id AS BP_AD_Org_ID, bp.bpartner_parent_id AS BP_BPartner_Parent_ID, bp.c_bp_group_id AS BP_C_BP_Group_ID, bp.c_dunning_id AS BP_C_Dunning_ID, bp.c_greeting_id AS BP_C_Greeting_ID, bp.c_invoiceschedule_id AS BP_C_InvoiceSchedule_ID, bp.c_paymentterm_id AS BP_C_PaymentTerm_ID, bp.created AS bp_created, bp.createdby AS BP_CreatedBy, bp.c_taxgroup_id AS BP_C_TaxGroup_ID, bp.deliveryrule AS bp_deliveryrule, bp.deliveryviarule AS bp_deliveryviarule,
bp.description AS bp_description, bp.dunninggrace AS bp_dunninggrace, bp.firstsale AS bp_firstsale, bp.flatdiscount AS bp_flatdiscount, bp.freightcostrule AS bp_freightcostrule, bp.invoicerule AS bp_invoicerule, bp.isactive AS bp_isactive, bp.iscustomer AS bp_iscustomer, bp.isdiscountprinted AS bp_isdiscountprinted, bp.isemployee AS bp_isemployee, bp.ismanufacturer AS bp_ismanufacturer, bp.isonetime AS bp_isonetime, bp.ispotaxexempt AS bp_ispotaxexempt, bp.isprospect AS bp_isprospect, bp.issalesrep AS bp_issalesrep, bp.issummary AS bp_issummary, bp.istaxexempt AS bp_istaxexempt, bp.isvendor AS bp_isvendor, bp.logo_id AS BP_Logo_ID, bp.m_discountschema_id AS BP_M_DiscountSchema_ID, bp.m_pricelist_id AS BP_M_PriceList_ID, bp.numberemployees AS bp_numberemployees, bp.paymentrule AS bp_paymentrule, bp.paymentrulepo AS bp_paymentrulepo, bp.po_discountschema_id AS BP_PO_DiscountSchema_ID, bp.po_paymentterm_id AS BP_PO_PaymentTerm_ID, bp.po_pricelist_id AS BP_PO_PriceList_ID, bp.poreference AS bp_poreference, bp.potentiallifetimevalue AS bp_potentiallifetimevalue, bp.rating AS bp_rating, bp.salesrep_id AS BP_SalesRep_ID, bp.salesvolume AS bp_salesvolume, bp.sendemail AS bp_sendemail, bp.shareofcustomer AS bp_shareofcustomer, bp.shelflifeminpct AS bp_shelflifeminpct, bp.so_creditlimit AS bp_so_creditlimit, bp.socreditstatus AS bp_socreditstatus, bp.so_creditused AS bp_so_creditused, bp.so_description AS bp_so_description, bp.totalopenbalance AS bp_totalopenbalance, bp.updated AS bp_updated, bp.updatedby AS BP_UpdatedBy, bp.url AS bp_url, bpg.ad_org_id AS C_Greeting_AD_Org_ID, bpg.isactive AS c_greeting_isactive, bpg.isfirstnameonly AS IsFirstNameOnly, bpg.name AS c_greeting_name, bpl.ad_org_id AS BP_Location_AD_Org_ID, bpl.c_bpartner_id AS BP_Location_C_BPartner_ID, bpl.created AS bp_location_created, bpl.createdby AS BP_Location_CreatedBy, bpl.c_salesregion_id AS BP_Location_C_SalesRegion_ID, bpl.fax AS bp_location_fax, bpl.isactive AS bp_location_isactive, bpl.isbillto AS bp_location_isbillto, bpl.isdn AS bp_location_isdn, bpl.ispayfrom AS bp_location_ispayfrom, bpl.isremitto AS bp_location_isremitto, bpl.isshipto AS bp_location_isshipto, bpl.name AS bp_location_name, bpl.phone AS bp_location_phone, bpl.phone2 AS bp_location_phone2, bpl.updated AS bp_location_updated, bpl.updatedby AS BP_Location_UpdatedBy, l.address1 AS Address1, l.address2 AS Address2, l.address3 AS Address3,
l.address4 AS Address4, l.ad_org_id AS C_Location_AD_Org_ID, l.c_city_id AS C_City_ID, l.c_country_id AS C_Country_ID, l.city AS City, l.created AS c_location_created, l.createdby AS C_Location_CreatedBy, l.c_region_id AS C_Region_ID, l.isactive AS c_location_isactive, l.regionname AS RegionName, l.updated AS c_location_updated, l.updatedby AS C_Location_UpdatedBy, bpc.ad_org_id AS AD_User_AD_Org_ID, bpc.ad_orgtrx_id AS AD_User_AD_OrgTrx_ID, bpc.birthday AS ad_user_ad_birthday, bpc.c_bpartner_id AS AD_User_C_BPartner_ID, bpc.c_bpartner_location_id AS AD_User_C_BPartner_Location_ID, bpc.c_greeting_id AS AD_User_C_Greeting_ID, bpc.comments AS ad_user_comments, bpc.created AS ad_user_created, bpc.createdby AS AD_User_CreatedBy, bpc.description AS ad_user_description, bpc.email AS ad_user_email, bpc.fax AS ad_user_fax, bpc.isactive AS ad_user_isactive, bpc.lastcontact AS ad_user_lastcontact, bpc.lastresult AS ad_user_lastresult, bpc.phone2 AS ad_user_phone2, bpc.supervisor_id AS AD_User_Supervisor_ID, bpc.updated AS ad_user_updated, bpc.updatedby AS AD_User_UpdatedBy, bpc.value AS ad_user_value, bpcg.ad_org_id AS C_User_Greeting_AD_Org_ID, bpcg.isactive AS c_user_greeting_isactive, bpcg.isfirstnameonly AS c_user_greeting_isfnameonly, bpcg.name AS c_user_greeting_name, oi.ad_org_id AS AD_OrgInfo_AD_Org_ID, oi.ad_orgtype_id AS AD_OrgType_ID, oi.c_calendar_id AS C_Calendar_ID, oi.created AS ad_orginfo_created, oi.createdby AS AD_OrgInfo_CreatedBy, oi.dropship_warehouse_id AS DropShip_Warehouse_ID, oi.duns AS ad_orginfo_duns, oi.email AS ad_orginfo_email, oi.fax AS ad_orginfo_fax, oi.isactive AS ad_orginfo_isactive, oi.m_warehouse_id AS AD_OrgInfo_M_Warehouse_ID, oi.parent_org_id AS Parent_Org_ID, oi.phone AS ad_orginfo_phone, oi.phone2 AS ad_orginfo_phone2, oi.receiptfootermsg AS ReceiptFooterMsg, oi.supervisor_id AS Supervisor_ID, oi.updated AS ad_orginfo_updated, oi.updatedby AS AD_OrgInfo_UpdatedBy, u.ad_org_id AS SalesRep_AD_Org_ID, u.ad_orgtrx_id AS SalesRep_AD_OrgTrx_ID, u.birthday AS salesrep_ad_birthday, u.c_bpartner_id AS SalesRep_C_BPartner_ID, u.c_bpartner_location_id AS SalesRep_C_BP_Location_ID, u.c_greeting_id AS SalesRep_C_Greeting_ID, u.comments AS salesrep_comments, u.created AS salesrep_created, u.createdby AS SalesRep_CreatedBy, u.description AS salesrep_description, u.email AS salesrep_email, u.fax AS salesrep_fax, u.isactive AS salesrep_isactive,
u.lastcontact AS salesrep_lastcontact, u.lastresult AS salesrep_lastresult, u.phone AS salesrep_phone, u.phone2 AS salesrep_phone2, u.supervisor_id AS SalesRep_Supervisor_ID, u.title AS salesrep_title, u.updated AS salesrep_updated, u.updatedby AS SalesRep_UpdatedBy, u.value AS salesrep_value, ubp.acqusitioncost AS salesrep_bp_acqusitioncost, ubp.actuallifetimevalue AS salesrep_bp_actuallifetimeval, ubp.ad_language AS salesrep_bp_ad_language, ubp.ad_orgbp_id AS SalesRep_BP_AD_OrgBP_ID, ubp.ad_org_id AS SalesRep_BP_AD_Org_ID, ubp.bpartner_parent_id AS SalesRep_BP_BPartner_Parent_ID, ubp.c_bp_group_id AS SalesRep_BP_C_BP_Group_ID, ubp.c_dunning_id AS SalesRep_BP_C_Dunning_ID, ubp.c_greeting_id AS SalesRep_BP_C_Greeting_ID, ubp.c_invoiceschedule_id AS SalesRep_BP_C_InvoiceSched_ID, ubp.c_paymentterm_id AS SalesRep_BP_C_PaymentTerm_ID, ubp.created AS salesrep_bp_created, ubp.createdby AS SalesRep_BP_CreatedBy, ubp.c_taxgroup_id AS SalesRep_BP_C_TaxGroup_ID, ubp.deliveryrule AS salesrep_bp_deliveryrule, ubp.deliveryviarule AS salesrep_bp_deliveryviarule, ubp.description AS salesrep_bp_description, ubp.dunninggrace AS salesrep_bp_dunninggrace, ubp.duns AS salesrep_bp_duns, ubp.firstsale AS salesrep_bp_firstsale, ubp.flatdiscount AS salesrep_bp_flatdiscount, ubp.freightcostrule AS salesrep_bp_freightcostrule, ubp.invoicerule AS salesrep_bp_invoicerule, ubp.isactive AS salesrep_bp_isactive, ubp.iscustomer AS salesrep_bp_iscustomer, ubp.isdiscountprinted AS salesrep_bp_isdiscountprinted, ubp.isemployee AS salesrep_bp_isemployee, ubp.ismanufacturer AS salesrep_bp_ismanufacturer, ubp.isonetime AS salesrep_bp_isonetime, ubp.ispotaxexempt AS salesrep_bp_ispotaxexempt, ubp.isprospect AS salesrep_bp_isprospect, ubp.issalesrep AS salesrep_bp_issalesrep, ubp.issummary AS salesrep_bp_issummary, ubp.istaxexempt AS salesrep_bp_istaxexempt, ubp.isvendor AS salesrep_bp_isvendor, ubp.logo_id AS SalesRep_BP_Logo_ID, ubp.m_discountschema_id AS SalesRep_BP_M_DiscountSchm_ID, ubp.m_pricelist_id AS SalesRep_BP_M_PriceList_ID, ubp.naics AS salesrep_bp_naics, ubp.name2 AS salesrep_bp_name2, ubp.numberemployees AS salesrep_bp_numberemployees, ubp.paymentrule AS salesrep_bp_paymentrule, ubp.paymentrulepo AS salesrep_bp_paymentrulepo, ubp.po_discountschema_id AS SalesRep_BP_PO_DiscountSchm_ID, ubp.po_paymentterm_id AS SalesRep_BP_PO_PaymentTerm_ID, ubp.po_pricelist_id AS SalesRep_BP_PO_PriceList_ID,
ubp.poreference AS salesrep_bp_poreference, ubp.potentiallifetimevalue AS salesrep_bp_potentiallifetime, ubp.rating AS salesrep_bp_rating, ubp.referenceno AS salesrep_bp_referenceno, ubp.salesrep_id AS SalesRep_BP_SalesRep_ID, ubp.salesvolume AS salesrep_bp_salesvolume, ubp.sendemail AS salesrep_bp_sendemail, ubp.shareofcustomer AS salesrep_bp_shareofcustomer, ubp.shelflifeminpct AS salesrep_bp_shelflifeminpct, ubp.so_creditlimit AS salesrep_bp_so_creditlimit, ubp.socreditstatus AS salesrep_bp_socreditstatus, ubp.so_creditused AS salesrep_bp_so_creditused, ubp.so_description AS salesrep_bp_so_description, ubp.taxid AS salesrep_bp_taxid, ubp.totalopenbalance AS salesrep_bp_totalopenbalance, ubp.updated AS salesrep_bp_updated, ubp.updatedby AS SalesRep_BP_UpdatedBy, ubp.url AS salesrep_bp_url, ubp.value AS salesrep_bp_value, bbp.acqusitioncost AS bill_bp_acqusitioncost, bbp.actuallifetimevalue AS bill_bp_actuallifetimevalue, bbp.ad_language AS bill_bp_ad_language, bbp.ad_orgbp_id AS Bill_BP_AD_OrgBP_ID, bbp.ad_org_id AS Bill_BP_AD_Org_ID, bbp.bpartner_parent_id AS Bill_BP_BPartner_Parent_ID, bbp.c_bp_group_id AS Bill_BP_C_BP_Group_ID, bbp.c_dunning_id AS Bill_BP_C_Dunning_ID, bbp.c_greeting_id AS Bill_BP_C_Greeting_ID, bbp.c_invoiceschedule_id AS Bill_BP_C_InvoiceSchedule_ID, bbp.c_paymentterm_id AS Bill_BP_C_PaymentTerm_ID, bbp.created AS bill_bp_created, bbp.createdby AS Bill_BP_CreatedBy, bbp.c_taxgroup_id AS Bill_BP_C_TaxGroup_ID, bbp.deliveryrule AS bill_bp_deliveryrule, bbp.deliveryviarule AS bill_bp_deliveryviarule, bbp.description AS bill_bp_description, bbp.dunninggrace AS bill_bp_dunninggrace, bbp.duns AS bill_bp_duns, bbp.firstsale AS bill_bp_firstsale, bbp.flatdiscount AS bill_bp_flatdiscount, bbp.freightcostrule AS bill_bp_freightcostrule, bbp.invoicerule AS bill_bp_invoicerule, bbp.isactive AS bill_bp_isactive, bbp.iscustomer AS bill_bp_iscustomer, bbp.isdiscountprinted AS bill_bp_isdiscountprinted, bbp.isemployee AS bill_bp_isemployee, bbp.ismanufacturer AS bill_bp_ismanufacturer, bbp.isonetime AS bill_bp_isonetime, bbp.ispotaxexempt AS bill_bp_ispotaxexempt, bbp.isprospect AS bill_bp_isprospect, bbp.issalesrep AS bill_bp_issalesrep, bbp.issummary AS bill_bp_issummary, bbp.istaxexempt AS bill_bp_istaxexempt, bbp.isvendor AS bill_bp_isvendor, bbp.logo_id AS Bill_BP_Logo_ID, bbp.m_discountschema_id AS Bill_BP_M_DiscountSchema_ID, bbp.m_pricelist_id AS Bill_BP_M_PriceList_ID,
bbp.naics AS bill_bp_naics, bbp.numberemployees AS bill_bp_numberemployees, bbp.paymentrule AS bill_bp_paymentrule, bbp.paymentrulepo AS bill_bp_paymentrulepo, bbp.po_discountschema_id AS Bill_BP_PO_DiscountSchema_ID, bbp.po_paymentterm_id AS Bill_BP_PO_PaymentTerm_ID, bbp.po_pricelist_id AS Bill_BP_PO_PriceList_ID, bbp.poreference AS bill_bp_poreference, bbp.potentiallifetimevalue AS bill_bp_potentiallifetimevalue, bbp.rating AS bill_bp_rating, bbp.referenceno AS bill_bp_referenceno, bbp.salesrep_id AS Bill_BP_SalesRep_ID, bbp.salesvolume AS bill_bp_salesvolume, bbp.sendemail AS bill_bp_sendemail, bbp.shareofcustomer AS bill_bp_shareofcustomer, bbp.shelflifeminpct AS bill_bp_shelflifeminpct, bbp.so_creditlimit AS bill_bp_so_creditlimit, bbp.socreditstatus AS bill_bp_socreditstatus, bbp.so_creditused AS bill_bp_so_creditused, bbp.so_description AS bill_bp_so_description, bbp.totalopenbalance AS bill_bp_totalopenbalance, bbp.updated AS bill_bp_updated, bbp.updatedby AS Bill_BP_UpdatedBy, bbp.url AS bill_bp_url, bbpl.ad_org_id AS Bill_BP_Location_AD_Org_ID, bbpl.c_bpartner_id AS Bill_BP_Location_C_BPartner_ID, bbpl.created AS bill_bp_location_created, bbpl.createdby AS Bill_BP_Location_CreatedBy, bbpl.c_salesregion_id AS Bill_BP_Location_C_SalesReg_ID, bbpl.fax AS bill_bp_location_fax, bbpl.isactive AS bill_bp_location_isactive, bbpl.isbillto AS bill_bp_location_isbillto, bbpl.isdn AS bill_bp_location_isdn, bbpl.ispayfrom AS bill_bp_location_ispayfrom, bbpl.isremitto AS bill_bp_location_isremitto, bbpl.isshipto AS bill_bp_location_isshipto, bbpl.name AS bill_bp_location_name, bbpl.phone AS bill_bp_location_phone, bbpl.phone2 AS bill_bp_location_phone2, bbpl.updated AS bill_bp_location_updated, bbpl.updatedby AS Bill_BP_Location_UpdatedBy, bbpc.ad_org_id AS Bill_User_AD_Org_ID, bbpc.ad_orgtrx_id AS Bill_User_AD_OrgTrx_ID, bbpc.birthday AS bill_user_ad_birthday, bbpc.c_bpartner_id AS Bill_User_C_BPartner_ID, bbpc.c_bpartner_location_id AS Bill_User_C_BP_Location_ID, bbpc.c_greeting_id AS Bill_User_C_Greeting_ID, bbpc.comments AS bill_user_comments, bbpc.created AS bill_user_created, bbpc.createdby AS Bill_User_CreatedBy, bbpc.description AS bill_user_description, bbpc.email AS bill_user_email, bbpc.fax AS bill_user_fax, bbpc.isactive AS bill_user_isactive, bbpc.lastcontact AS bill_user_lastcontact, bbpc.lastresult AS bill_user_lastresult, bbpc.phone2 AS bill_user_phone2,
bbpc.supervisor_id AS Bill_User_Supervisor_ID, bbpc.updated AS bill_user_updated, bbpc.updatedby AS Bill_User_UpdatedBy, bbpc.value AS bill_user_value, cur.cursymbol AS CurSymbol, cur.description AS cur_description FROM c_order o
JOIN c_doctype dt ON o.c_doctype_id = dt.c_doctype_id
JOIN m_warehouse wh ON o.m_warehouse_id = wh.m_warehouse_id
JOIN c_paymentterm pt ON o.c_paymentterm_id = pt.c_paymentterm_id
JOIN c_bpartner bp ON o.c_bpartner_id = bp.c_bpartner_id
LEFT JOIN c_greeting bpg ON bp.c_greeting_id = bpg.c_greeting_id
JOIN c_bpartner_location bpl ON o.c_bpartner_location_id = bpl.c_bpartner_location_id
JOIN c_location l ON bpl.c_location_id = l.c_location_id
LEFT JOIN ad_user bpc ON o.ad_user_id = bpc.ad_user_id
LEFT JOIN c_greeting bpcg ON bpc.c_greeting_id = bpcg.c_greeting_id
JOIN ad_orginfo oi ON o.ad_org_id = oi.ad_org_id
JOIN ad_clientinfo ci ON o.ad_client_id = ci.ad_client_id
LEFT JOIN ad_user u ON o.salesrep_id = u.ad_user_id
LEFT JOIN c_bpartner ubp ON u.c_bpartner_id = ubp.c_bpartner_id
JOIN c_bpartner bbp ON o.bill_bpartner_id = bbp.c_bpartner_id
JOIN c_bpartner_location bbpl ON o.bill_location_id = bbpl.c_bpartner_location_id
LEFT JOIN ad_user bbpc ON o.bill_user_id = bbpc.ad_user_id
LEFT JOIN c_currency cur ON o.c_currency_id = cur.c_currency_id
;
-- Feb 15, 2022, 8:07:14 PM CET
UPDATE AD_ViewColumn SET ColumnSQL='COALESCE(l.postal,'''') || COALESCE(l.postal_add,'''')',Updated=TO_DATE('2022-02-15 20:07:14','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_ViewColumn_ID=205195
;
-- Feb 15, 2022, 8:07:37 PM CET
CREATE OR REPLACE VIEW C_Order_Header_vt(AD_Client_ID, AD_Org_ID, IsActive, Created, CreatedBy, Updated, UpdatedBy, AD_Language, C_Order_ID, IsSOTrx, DocumentNo, DocStatus, C_DocType_ID, C_BPartner_ID, BPValue, BPTaxID, NAICS, DUNS, Org_Location_ID, TaxID, M_Warehouse_ID, Warehouse_Location_ID, DocumentType, DocumentTypeNote, SalesRep_ID, SalesRep_Name, DateOrdered, DatePromised, BPGreeting, Name, Name2, BPContactGreeting, Title, Phone, ContactName, C_Location_ID, Postal, ReferenceNo, Bill_BPartner_ID, Bill_Location_ID, Bill_User_ID, Bill_BPValue, Bill_BPTaxID, Bill_Name, Bill_Name2, Bill_Title, Bill_Phone, Bill_ContactName, Bill_C_Location_ID, Description, POReference, C_Currency_ID, PaymentTerm, PaymentTermNote, C_Charge_ID, ChargeAmt, TotalLines, GrandTotal, AmtInWords, M_PriceList_ID, IsTaxIncluded, Volume, Weight, C_Campaign_ID, C_Project_ID, C_Activity_ID, M_Shipper_ID, DeliveryRule, DeliveryViaRule, PriorityRule, InvoiceRule, Logo_ID, AD_OrgTrx_ID, AD_User_ID, AmountRefunded, AmountTendered, C_BPartner_Location_ID, C_CashLine_ID, C_CashPlanLine_ID, C_ConversionType_ID, C_DocTypeTarget_ID, CopyFrom, C_Payment_ID, C_PaymentTerm_ID, C_POS_ID, DateAcct, DatePrinted, DocAction, DropShip_BPartner_ID, DropShip_Location_ID, DropShip_User_ID, FreightAmt, FreightCostRule, IsApproved, IsCreditApproved, IsDelivered, IsDiscountPrinted, IsDropShip, IsInvoiced, IsPayScheduleValid, IsPrinted, IsSelected, IsSelfService, IsTransferred, Link_Order_ID, M_FreightCategory_ID, OrderType, Pay_BPartner_ID, Pay_Location_ID, PaymentRule, Posted, Processed, ProcessedOn, PromotionCode, Ref_Order_ID, SendEMail, User1_ID, User2_ID, M_Warehouse_AD_Org_ID, m_warehouse_description, m_warehouse_isactive, IsDisallowNegativeInv, IsInTransit, M_WarehouseSource_ID, m_warehouse_name, ReplenishmentClass, Separator, m_warehouse_value, C_PaymentTerm_AD_Org_ID, AfterDelivery, c_paymentterm_description, Discount, Discount2, DiscountDays, DiscountDays2, FixMonthCutoff, FixMonthDay, FixMonthOffset, GraceDays, c_paymentterm_isactive, IsDefault, IsDueFixed, IsNextBusinessDay, IsValid, NetDay, NetDays, PaymentTermUsage, m_paymentterm_value, bp_acqusitioncost, bp_actuallifetimevalue, bp_ad_language, BP_AD_OrgBP_ID, BP_AD_Org_ID, BP_BPartner_Parent_ID, BP_C_BP_Group_ID, BP_C_Dunning_ID, BP_C_Greeting_ID, BP_C_InvoiceSchedule_ID, BP_C_PaymentTerm_ID, bp_created, BP_CreatedBy, BP_C_TaxGroup_ID, bp_deliveryrule,
bp_deliveryviarule, bp_description, bp_dunninggrace, bp_firstsale, bp_flatdiscount, bp_freightcostrule, bp_invoicerule, bp_isactive, bp_iscustomer, bp_isdiscountprinted, bp_isemployee, bp_ismanufacturer, bp_isonetime, bp_ispotaxexempt, bp_isprospect, bp_issalesrep, bp_issummary, bp_istaxexempt, bp_isvendor, BP_Logo_ID, BP_M_DiscountSchema_ID, BP_M_PriceList_ID, bp_numberemployees, bp_paymentrule, bp_paymentrulepo, BP_PO_DiscountSchema_ID, BP_PO_PaymentTerm_ID, BP_PO_PriceList_ID, bp_poreference, bp_potentiallifetimevalue, bp_rating, BP_SalesRep_ID, bp_salesvolume, bp_sendemail, bp_shareofcustomer, bp_shelflifeminpct, bp_so_creditlimit, bp_socreditstatus, bp_so_creditused, bp_so_description, bp_totalopenbalance, bp_updated, BP_UpdatedBy, bp_url, C_Greeting_AD_Org_ID, c_greeting_isactive, IsFirstNameOnly, c_greeting_name, BP_Location_AD_Org_ID, BP_Location_C_BPartner_ID, bp_location_created, BP_Location_CreatedBy, BP_Location_C_SalesRegion_ID, bp_location_fax, bp_location_isactive, bp_location_isbillto, bp_location_isdn, bp_location_ispayfrom, bp_location_isremitto, bp_location_isshipto, bp_location_name, bp_location_phone, bp_location_phone2, bp_location_updated, BP_Location_UpdatedBy, Address1, Address2, Address3, Address4, C_Location_AD_Org_ID, C_City_ID, C_Country_ID, City, c_location_created, C_Location_CreatedBy, C_Region_ID, c_location_isactive, RegionName, c_location_updated, C_Location_UpdatedBy, AD_User_AD_Org_ID, AD_User_AD_OrgTrx_ID, ad_user_ad_birthday, AD_User_C_BPartner_ID, AD_User_C_BPartner_Location_ID, AD_User_C_Greeting_ID, ad_user_comments, ad_user_created, AD_User_CreatedBy, ad_user_description, ad_user_email, ad_user_fax, ad_user_isactive, ad_user_lastcontact, ad_user_lastresult, ad_user_phone2, AD_User_Supervisor_ID, ad_user_updated, AD_User_UpdatedBy, ad_user_value, C_User_Greeting_AD_Org_ID, c_user_greeting_isactive, c_user_greeting_isfnameonly, c_user_greeting_name, AD_OrgInfo_AD_Org_ID, AD_OrgType_ID, C_Calendar_ID, ad_orginfo_created, AD_OrgInfo_CreatedBy, DropShip_Warehouse_ID, ad_orginfo_duns, ad_orginfo_email, ad_orginfo_fax, ad_orginfo_isactive, AD_OrgInfo_M_Warehouse_ID, Parent_Org_ID, ad_orginfo_phone, ad_orginfo_phone2, ReceiptFooterMsg, Supervisor_ID, ad_orginfo_updated, AD_OrgInfo_UpdatedBy, SalesRep_AD_Org_ID, SalesRep_AD_OrgTrx_ID, salesrep_ad_birthday, SalesRep_C_BPartner_ID, SalesRep_C_BP_Location_ID, SalesRep_C_Greeting_ID,
salesrep_comments, salesrep_created, SalesRep_CreatedBy, salesrep_description, salesrep_email, salesrep_fax, salesrep_isactive, salesrep_lastcontact, salesrep_lastresult, salesrep_phone, salesrep_phone2, SalesRep_Supervisor_ID, salesrep_title, salesrep_updated, SalesRep_UpdatedBy, salesrep_value, salesrep_bp_acqusitioncost, salesrep_bp_actuallifetimeval, salesrep_bp_ad_language, SalesRep_BP_AD_OrgBP_ID, SalesRep_BP_AD_Org_ID, SalesRep_BP_BPartner_Parent_ID, SalesRep_BP_C_BP_Group_ID, SalesRep_BP_C_Dunning_ID, SalesRep_BP_C_Greeting_ID, SalesRep_BP_C_InvoiceSched_ID, SalesRep_BP_C_PaymentTerm_ID, salesrep_bp_created, SalesRep_BP_CreatedBy, SalesRep_BP_C_TaxGroup_ID, salesrep_bp_deliveryrule, salesrep_bp_deliveryviarule, salesrep_bp_description, salesrep_bp_dunninggrace, salesrep_bp_duns, salesrep_bp_firstsale, salesrep_bp_flatdiscount, salesrep_bp_freightcostrule, salesrep_bp_invoicerule, salesrep_bp_isactive, salesrep_bp_iscustomer, salesrep_bp_isdiscountprinted, salesrep_bp_isemployee, salesrep_bp_ismanufacturer, salesrep_bp_isonetime, salesrep_bp_ispotaxexempt, salesrep_bp_isprospect, salesrep_bp_issalesrep, salesrep_bp_issummary, salesrep_bp_istaxexempt, salesrep_bp_isvendor, SalesRep_BP_Logo_ID, SalesRep_BP_M_DiscountSchm_ID, SalesRep_BP_M_PriceList_ID, salesrep_bp_naics, salesrep_bp_name2, salesrep_bp_numberemployees, salesrep_bp_paymentrule, salesrep_bp_paymentrulepo, SalesRep_BP_PO_DiscountSchm_ID, SalesRep_BP_PO_PaymentTerm_ID, SalesRep_BP_PO_PriceList_ID, salesrep_bp_poreference, salesrep_bp_potentiallifetime, salesrep_bp_rating, salesrep_bp_referenceno, SalesRep_BP_SalesRep_ID, salesrep_bp_salesvolume, salesrep_bp_sendemail, salesrep_bp_shareofcustomer, salesrep_bp_shelflifeminpct, salesrep_bp_so_creditlimit, salesrep_bp_socreditstatus, salesrep_bp_so_creditused, salesrep_bp_so_description, salesrep_bp_taxid, salesrep_bp_totalopenbalance, salesrep_bp_updated, SalesRep_BP_UpdatedBy, salesrep_bp_url, salesrep_bp_value, bill_bp_acqusitioncost, bill_bp_actuallifetimevalue, bill_bp_ad_language, Bill_BP_AD_OrgBP_ID, Bill_BP_AD_Org_ID, Bill_BP_BPartner_Parent_ID, Bill_BP_C_BP_Group_ID, Bill_BP_C_Dunning_ID, Bill_BP_C_Greeting_ID, Bill_BP_C_InvoiceSchedule_ID, Bill_BP_C_PaymentTerm_ID, bill_bp_created, Bill_BP_CreatedBy, Bill_BP_C_TaxGroup_ID, bill_bp_deliveryrule, bill_bp_deliveryviarule, bill_bp_description, bill_bp_dunninggrace, bill_bp_duns, bill_bp_firstsale,
bill_bp_flatdiscount, bill_bp_freightcostrule, bill_bp_invoicerule, bill_bp_isactive, bill_bp_iscustomer, bill_bp_isdiscountprinted, bill_bp_isemployee, bill_bp_ismanufacturer, bill_bp_isonetime, bill_bp_ispotaxexempt, bill_bp_isprospect, bill_bp_issalesrep, bill_bp_issummary, bill_bp_istaxexempt, bill_bp_isvendor, Bill_BP_Logo_ID, Bill_BP_M_DiscountSchema_ID, Bill_BP_M_PriceList_ID, bill_bp_naics, bill_bp_numberemployees, bill_bp_paymentrule, bill_bp_paymentrulepo, Bill_BP_PO_DiscountSchema_ID, Bill_BP_PO_PaymentTerm_ID, Bill_BP_PO_PriceList_ID, bill_bp_poreference, bill_bp_potentiallifetimevalue, bill_bp_rating, bill_bp_referenceno, Bill_BP_SalesRep_ID, bill_bp_salesvolume, bill_bp_sendemail, bill_bp_shareofcustomer, bill_bp_shelflifeminpct, bill_bp_so_creditlimit, bill_bp_socreditstatus, bill_bp_so_creditused, bill_bp_so_description, bill_bp_totalopenbalance, bill_bp_updated, Bill_BP_UpdatedBy, bill_bp_url, Bill_BP_Location_AD_Org_ID, Bill_BP_Location_C_BPartner_ID, bill_bp_location_created, Bill_BP_Location_CreatedBy, Bill_BP_Location_C_SalesReg_ID, bill_bp_location_fax, bill_bp_location_isactive, bill_bp_location_isbillto, bill_bp_location_isdn, bill_bp_location_ispayfrom, bill_bp_location_isremitto, bill_bp_location_isshipto, bill_bp_location_name, bill_bp_location_phone, bill_bp_location_phone2, bill_bp_location_updated, Bill_BP_Location_UpdatedBy, Bill_User_AD_Org_ID, Bill_User_AD_OrgTrx_ID, bill_user_ad_birthday, Bill_User_C_BPartner_ID, Bill_User_C_BP_Location_ID, Bill_User_C_Greeting_ID, bill_user_comments, bill_user_created, Bill_User_CreatedBy, bill_user_description, bill_user_email, bill_user_fax, bill_user_isactive, bill_user_lastcontact, bill_user_lastresult, bill_user_phone2, Bill_User_Supervisor_ID, bill_user_updated, Bill_User_UpdatedBy, bill_user_value, CurSymbol, cur_description) AS SELECT o.ad_client_id AS AD_Client_ID, o.ad_org_id AS AD_Org_ID, o.isactive AS IsActive, o.created AS Created, o.createdby AS CreatedBy, o.updated AS Updated, o.updatedby AS UpdatedBy, dt.ad_language AS AD_Language, o.c_order_id AS C_Order_ID, o.issotrx AS IsSOTrx, o.documentno AS DocumentNo, o.docstatus AS DocStatus, o.c_doctype_id AS C_DocType_ID, o.c_bpartner_id AS C_BPartner_ID, bp.value AS BPValue, bp.taxid AS BPTaxID, bp.naics AS NAICS, bp.duns AS DUNS, oi.c_location_id AS Org_Location_ID, oi.taxid AS TaxID, o.m_warehouse_id AS M_Warehouse_ID, wh.c_location_id AS Warehouse_Location_ID,
dt.printname AS DocumentType, dt.documentnote AS DocumentTypeNote, o.salesrep_id AS SalesRep_ID, COALESCE(ubp.name, u.name) AS SalesRep_Name, o.dateordered AS DateOrdered, o.datepromised AS DatePromised, bpgt.greeting AS BPGreeting, bp.name AS Name, bp.name2 AS Name2, bpcgt.greeting AS BPContactGreeting, bpc.title AS Title, bpc.phone AS Phone, NULLIF(bpc.name, bp.name) AS ContactName, bpl.c_location_id AS C_Location_ID, COALESCE(l.postal,'') || COALESCE(l.postal_add,'') AS Postal, bp.referenceno AS ReferenceNo, o.bill_bpartner_id AS Bill_BPartner_ID, o.bill_location_id AS Bill_Location_ID, o.bill_user_id AS Bill_User_ID, bbp.value AS Bill_BPValue, bbp.taxid AS Bill_BPTaxID, bbp.name AS Bill_Name, bbp.name2 AS Bill_Name2, bbpc.title AS Bill_Title, bbpc.phone AS Bill_Phone, NULLIF(bbpc.name, bbp.name) AS Bill_ContactName, bbpl.c_location_id AS Bill_C_Location_ID, o.description AS Description, o.poreference AS POReference, o.c_currency_id AS C_Currency_ID, ptt.name AS PaymentTerm, ptt.documentnote AS PaymentTermNote, o.c_charge_id AS C_Charge_ID, o.chargeamt AS ChargeAmt, o.totallines AS TotalLines, o.grandtotal AS GrandTotal, o.grandtotal AS AmtInWords, o.m_pricelist_id AS M_PriceList_ID, o.istaxincluded AS IsTaxIncluded, o.volume AS Volume, o.weight AS Weight, o.c_campaign_id AS C_Campaign_ID, o.c_project_id AS C_Project_ID, o.c_activity_id AS C_Activity_ID, o.m_shipper_id AS M_Shipper_ID, o.deliveryrule AS DeliveryRule, o.deliveryviarule AS DeliveryViaRule, o.priorityrule AS PriorityRule, o.invoicerule AS InvoiceRule, COALESCE(oi.logo_id, ci.logo_id) AS Logo_ID, o.ad_orgtrx_id AS AD_OrgTrx_ID, o.ad_user_id AS AD_User_ID, o.amountrefunded AS AmountRefunded, o.amounttendered AS AmountTendered, o.c_bpartner_location_id AS C_BPartner_Location_ID, o.c_cashline_id AS C_CashLine_ID, o.c_cashplanline_id AS C_CashPlanLine_ID, o.c_conversiontype_id AS C_ConversionType_ID, o.c_doctypetarget_id AS C_DocTypeTarget_ID, o.copyfrom AS CopyFrom, o.c_payment_id AS C_Payment_ID, o.c_paymentterm_id AS C_PaymentTerm_ID, o.c_pos_id AS C_POS_ID, o.dateacct AS DateAcct, o.dateprinted AS DatePrinted, o.docaction AS DocAction, o.dropship_bpartner_id AS DropShip_BPartner_ID, o.dropship_location_id AS DropShip_Location_ID, o.dropship_user_id AS DropShip_User_ID, o.freightamt AS FreightAmt, o.freightcostrule AS FreightCostRule, o.isapproved AS IsApproved, o.iscreditapproved AS IsCreditApproved,
o.isdelivered AS IsDelivered, o.isdiscountprinted AS IsDiscountPrinted, o.isdropship AS IsDropShip, o.isinvoiced AS IsInvoiced, o.ispayschedulevalid AS IsPayScheduleValid, o.isprinted AS IsPrinted, o.isselected AS IsSelected, o.isselfservice AS IsSelfService, o.istransferred AS IsTransferred, o.link_order_id AS Link_Order_ID, o.m_freightcategory_id AS M_FreightCategory_ID, o.ordertype AS OrderType, o.pay_bpartner_id AS Pay_BPartner_ID, o.pay_location_id AS Pay_Location_ID, o.paymentrule AS PaymentRule, o.posted AS Posted, o.processed AS Processed, o.processedon AS ProcessedOn, o.promotioncode AS PromotionCode, o.ref_order_id AS Ref_Order_ID, o.sendemail AS SendEMail, o.user1_id AS User1_ID, o.user2_id AS User2_ID, wh.ad_org_id AS M_Warehouse_AD_Org_ID, wh.description AS m_warehouse_description, wh.isactive AS m_warehouse_isactive, wh.isdisallownegativeinv AS IsDisallowNegativeInv, wh.isintransit AS IsInTransit, wh.m_warehousesource_id AS M_WarehouseSource_ID, wh.name AS m_warehouse_name, wh.replenishmentclass AS ReplenishmentClass, wh.separator AS Separator, wh.value AS m_warehouse_value, ptt.ad_org_id AS C_PaymentTerm_AD_Org_ID, pt.afterdelivery AS AfterDelivery, ptt.description AS c_paymentterm_description, pt.discount AS Discount, pt.discount2 AS Discount2, pt.discountdays AS DiscountDays, pt.discountdays2 AS DiscountDays2, pt.fixmonthcutoff AS FixMonthCutoff, pt.fixmonthday AS FixMonthDay, pt.fixmonthoffset AS FixMonthOffset, pt.gracedays AS GraceDays, ptt.isactive AS c_paymentterm_isactive, pt.isdefault AS IsDefault, pt.isduefixed AS IsDueFixed, pt.isnextbusinessday AS IsNextBusinessDay, pt.isvalid AS IsValid, pt.netday AS NetDay, pt.netdays AS NetDays, pt.paymenttermusage AS PaymentTermUsage, pt.value AS m_paymentterm_value, bp.acqusitioncost AS bp_acqusitioncost, bp.actuallifetimevalue AS bp_actuallifetimevalue, bp.ad_language AS bp_ad_language, bp.ad_orgbp_id AS BP_AD_OrgBP_ID, bp.ad_org_id AS BP_AD_Org_ID, bp.bpartner_parent_id AS BP_BPartner_Parent_ID, bp.c_bp_group_id AS BP_C_BP_Group_ID, bp.c_dunning_id AS BP_C_Dunning_ID, bp.c_greeting_id AS BP_C_Greeting_ID, bp.c_invoiceschedule_id AS BP_C_InvoiceSchedule_ID, bp.c_paymentterm_id AS BP_C_PaymentTerm_ID, bp.created AS bp_created, bp.createdby AS BP_CreatedBy, bp.c_taxgroup_id AS BP_C_TaxGroup_ID, bp.deliveryrule AS bp_deliveryrule, bp.deliveryviarule AS bp_deliveryviarule, bp.description AS bp_description,
bp.dunninggrace AS bp_dunninggrace, bp.firstsale AS bp_firstsale, bp.flatdiscount AS bp_flatdiscount, bp.freightcostrule AS bp_freightcostrule, bp.invoicerule AS bp_invoicerule, bp.isactive AS bp_isactive, bp.iscustomer AS bp_iscustomer, bp.isdiscountprinted AS bp_isdiscountprinted, bp.isemployee AS bp_isemployee, bp.ismanufacturer AS bp_ismanufacturer, bp.isonetime AS bp_isonetime, bp.ispotaxexempt AS bp_ispotaxexempt, bp.isprospect AS bp_isprospect, bp.issalesrep AS bp_issalesrep, bp.issummary AS bp_issummary, bp.istaxexempt AS bp_istaxexempt, bp.isvendor AS bp_isvendor, bp.logo_id AS BP_Logo_ID, bp.m_discountschema_id AS BP_M_DiscountSchema_ID, bp.m_pricelist_id AS BP_M_PriceList_ID, bp.numberemployees AS bp_numberemployees, bp.paymentrule AS bp_paymentrule, bp.paymentrulepo AS bp_paymentrulepo, bp.po_discountschema_id AS BP_PO_DiscountSchema_ID, bp.po_paymentterm_id AS BP_PO_PaymentTerm_ID, bp.po_pricelist_id AS BP_PO_PriceList_ID, bp.poreference AS bp_poreference, bp.potentiallifetimevalue AS bp_potentiallifetimevalue, bp.rating AS bp_rating, bp.salesrep_id AS BP_SalesRep_ID, bp.salesvolume AS bp_salesvolume, bp.sendemail AS bp_sendemail, bp.shareofcustomer AS bp_shareofcustomer, bp.shelflifeminpct AS bp_shelflifeminpct, bp.so_creditlimit AS bp_so_creditlimit, bp.socreditstatus AS bp_socreditstatus, bp.so_creditused AS bp_so_creditused, bp.so_description AS bp_so_description, bp.totalopenbalance AS bp_totalopenbalance, bp.updated AS bp_updated, bp.updatedby AS BP_UpdatedBy, bp.url AS bp_url, bpgt.ad_org_id AS C_Greeting_AD_Org_ID, bpgt.isactive AS c_greeting_isactive, bpg.isfirstnameonly AS IsFirstNameOnly, bpgt.name AS c_greeting_name, bpl.ad_org_id AS BP_Location_AD_Org_ID, bpl.c_bpartner_id AS BP_Location_C_BPartner_ID, bpl.created AS bp_location_created, bpl.createdby AS BP_Location_CreatedBy, bpl.c_salesregion_id AS BP_Location_C_SalesRegion_ID, bpl.fax AS bp_location_fax, bpl.isactive AS bp_location_isactive, bpl.isbillto AS bp_location_isbillto, bpl.isdn AS bp_location_isdn, bpl.ispayfrom AS bp_location_ispayfrom, bpl.isremitto AS bp_location_isremitto, bpl.isshipto AS bp_location_isshipto, bpl.name AS bp_location_name, bpl.phone AS bp_location_phone, bpl.phone2 AS bp_location_phone2, bpl.updated AS bp_location_updated, bpl.updatedby AS BP_Location_UpdatedBy, l.address1 AS Address1, l.address2 AS Address2, l.address3 AS Address3, l.address4 AS Address4,
l.ad_org_id AS C_Location_AD_Org_ID, l.c_city_id AS C_City_ID, l.c_country_id AS C_Country_ID, l.city AS City, l.created AS c_location_created, l.createdby AS C_Location_CreatedBy, l.c_region_id AS C_Region_ID, l.isactive AS c_location_isactive, l.regionname AS RegionName, l.updated AS c_location_updated, l.updatedby AS C_Location_UpdatedBy, bpc.ad_org_id AS AD_User_AD_Org_ID, bpc.ad_orgtrx_id AS AD_User_AD_OrgTrx_ID, bpc.birthday AS ad_user_ad_birthday, bpc.c_bpartner_id AS AD_User_C_BPartner_ID, bpc.c_bpartner_location_id AS AD_User_C_BPartner_Location_ID, bpc.c_greeting_id AS AD_User_C_Greeting_ID, bpc.comments AS ad_user_comments, bpc.created AS ad_user_created, bpc.createdby AS AD_User_CreatedBy, bpc.description AS ad_user_description, bpc.email AS ad_user_email, bpc.fax AS ad_user_fax, bpc.isactive AS ad_user_isactive, bpc.lastcontact AS ad_user_lastcontact, bpc.lastresult AS ad_user_lastresult, bpc.phone2 AS ad_user_phone2, bpc.supervisor_id AS AD_User_Supervisor_ID, bpc.updated AS ad_user_updated, bpc.updatedby AS AD_User_UpdatedBy, bpc.value AS ad_user_value, bpcgt.ad_org_id AS C_User_Greeting_AD_Org_ID, bpcgt.isactive AS c_user_greeting_isactive, bpcg.isfirstnameonly AS c_user_greeting_isfnameonly, bpcgt.name AS c_user_greeting_name, oi.ad_org_id AS AD_OrgInfo_AD_Org_ID, oi.ad_orgtype_id AS AD_OrgType_ID, oi.c_calendar_id AS C_Calendar_ID, oi.created AS ad_orginfo_created, oi.createdby AS AD_OrgInfo_CreatedBy, oi.dropship_warehouse_id AS DropShip_Warehouse_ID, oi.duns AS ad_orginfo_duns, oi.email AS ad_orginfo_email, oi.fax AS ad_orginfo_fax, oi.isactive AS ad_orginfo_isactive, oi.m_warehouse_id AS AD_OrgInfo_M_Warehouse_ID, oi.parent_org_id AS Parent_Org_ID, oi.phone AS ad_orginfo_phone, oi.phone2 AS ad_orginfo_phone2, oi.receiptfootermsg AS ReceiptFooterMsg, oi.supervisor_id AS Supervisor_ID, oi.updated AS ad_orginfo_updated, oi.updatedby AS AD_OrgInfo_UpdatedBy, u.ad_org_id AS SalesRep_AD_Org_ID, u.ad_orgtrx_id AS SalesRep_AD_OrgTrx_ID, u.birthday AS salesrep_ad_birthday, u.c_bpartner_id AS SalesRep_C_BPartner_ID, u.c_bpartner_location_id AS SalesRep_C_BP_Location_ID, u.c_greeting_id AS SalesRep_C_Greeting_ID, u.comments AS salesrep_comments, u.created AS salesrep_created, u.createdby AS SalesRep_CreatedBy, u.description AS salesrep_description, u.email AS salesrep_email, u.fax AS salesrep_fax, u.isactive AS salesrep_isactive, u.lastcontact AS salesrep_lastcontact,
u.lastresult AS salesrep_lastresult, u.phone AS salesrep_phone, u.phone2 AS salesrep_phone2, u.supervisor_id AS SalesRep_Supervisor_ID, u.title AS salesrep_title, u.updated AS salesrep_updated, u.updatedby AS SalesRep_UpdatedBy, u.value AS salesrep_value, ubp.acqusitioncost AS salesrep_bp_acqusitioncost, ubp.actuallifetimevalue AS salesrep_bp_actuallifetimeval, ubp.ad_language AS salesrep_bp_ad_language, ubp.ad_orgbp_id AS SalesRep_BP_AD_OrgBP_ID, ubp.ad_org_id AS SalesRep_BP_AD_Org_ID, ubp.bpartner_parent_id AS SalesRep_BP_BPartner_Parent_ID, ubp.c_bp_group_id AS SalesRep_BP_C_BP_Group_ID, ubp.c_dunning_id AS SalesRep_BP_C_Dunning_ID, ubp.c_greeting_id AS SalesRep_BP_C_Greeting_ID, ubp.c_invoiceschedule_id AS SalesRep_BP_C_InvoiceSched_ID, ubp.c_paymentterm_id AS SalesRep_BP_C_PaymentTerm_ID, ubp.created AS salesrep_bp_created, ubp.createdby AS SalesRep_BP_CreatedBy, ubp.c_taxgroup_id AS SalesRep_BP_C_TaxGroup_ID, ubp.deliveryrule AS salesrep_bp_deliveryrule, ubp.deliveryviarule AS salesrep_bp_deliveryviarule, ubp.description AS salesrep_bp_description, ubp.dunninggrace AS salesrep_bp_dunninggrace, ubp.duns AS salesrep_bp_duns, ubp.firstsale AS salesrep_bp_firstsale, ubp.flatdiscount AS salesrep_bp_flatdiscount, ubp.freightcostrule AS salesrep_bp_freightcostrule, ubp.invoicerule AS salesrep_bp_invoicerule, ubp.isactive AS salesrep_bp_isactive, ubp.iscustomer AS salesrep_bp_iscustomer, ubp.isdiscountprinted AS salesrep_bp_isdiscountprinted, ubp.isemployee AS salesrep_bp_isemployee, ubp.ismanufacturer AS salesrep_bp_ismanufacturer, ubp.isonetime AS salesrep_bp_isonetime, ubp.ispotaxexempt AS salesrep_bp_ispotaxexempt, ubp.isprospect AS salesrep_bp_isprospect, ubp.issalesrep AS salesrep_bp_issalesrep, ubp.issummary AS salesrep_bp_issummary, ubp.istaxexempt AS salesrep_bp_istaxexempt, ubp.isvendor AS salesrep_bp_isvendor, ubp.logo_id AS SalesRep_BP_Logo_ID, ubp.m_discountschema_id AS SalesRep_BP_M_DiscountSchm_ID, ubp.m_pricelist_id AS SalesRep_BP_M_PriceList_ID, ubp.naics AS salesrep_bp_naics, ubp.name2 AS salesrep_bp_name2, ubp.numberemployees AS salesrep_bp_numberemployees, ubp.paymentrule AS salesrep_bp_paymentrule, ubp.paymentrulepo AS salesrep_bp_paymentrulepo, ubp.po_discountschema_id AS SalesRep_BP_PO_DiscountSchm_ID, ubp.po_paymentterm_id AS SalesRep_BP_PO_PaymentTerm_ID, ubp.po_pricelist_id AS SalesRep_BP_PO_PriceList_ID, ubp.poreference AS salesrep_bp_poreference,
ubp.potentiallifetimevalue AS salesrep_bp_potentiallifetime, ubp.rating AS salesrep_bp_rating, ubp.referenceno AS salesrep_bp_referenceno, ubp.salesrep_id AS SalesRep_BP_SalesRep_ID, ubp.salesvolume AS salesrep_bp_salesvolume, ubp.sendemail AS salesrep_bp_sendemail, ubp.shareofcustomer AS salesrep_bp_shareofcustomer, ubp.shelflifeminpct AS salesrep_bp_shelflifeminpct, ubp.so_creditlimit AS salesrep_bp_so_creditlimit, ubp.socreditstatus AS salesrep_bp_socreditstatus, ubp.so_creditused AS salesrep_bp_so_creditused, ubp.so_description AS salesrep_bp_so_description, ubp.taxid AS salesrep_bp_taxid, ubp.totalopenbalance AS salesrep_bp_totalopenbalance, ubp.updated AS salesrep_bp_updated, ubp.updatedby AS SalesRep_BP_UpdatedBy, ubp.url AS salesrep_bp_url, ubp.value AS salesrep_bp_value, bbp.acqusitioncost AS bill_bp_acqusitioncost, bbp.actuallifetimevalue AS bill_bp_actuallifetimevalue, bbp.ad_language AS bill_bp_ad_language, bbp.ad_orgbp_id AS Bill_BP_AD_OrgBP_ID, bbp.ad_org_id AS Bill_BP_AD_Org_ID, bbp.bpartner_parent_id AS Bill_BP_BPartner_Parent_ID, bbp.c_bp_group_id AS Bill_BP_C_BP_Group_ID, bbp.c_dunning_id AS Bill_BP_C_Dunning_ID, bbp.c_greeting_id AS Bill_BP_C_Greeting_ID, bbp.c_invoiceschedule_id AS Bill_BP_C_InvoiceSchedule_ID, bbp.c_paymentterm_id AS Bill_BP_C_PaymentTerm_ID, bbp.created AS bill_bp_created, bbp.createdby AS Bill_BP_CreatedBy, bbp.c_taxgroup_id AS Bill_BP_C_TaxGroup_ID, bbp.deliveryrule AS bill_bp_deliveryrule, bbp.deliveryviarule AS bill_bp_deliveryviarule, bbp.description AS bill_bp_description, bbp.dunninggrace AS bill_bp_dunninggrace, bbp.duns AS bill_bp_duns, bbp.firstsale AS bill_bp_firstsale, bbp.flatdiscount AS bill_bp_flatdiscount, bbp.freightcostrule AS bill_bp_freightcostrule, bbp.invoicerule AS bill_bp_invoicerule, bbp.isactive AS bill_bp_isactive, bbp.iscustomer AS bill_bp_iscustomer, bbp.isdiscountprinted AS bill_bp_isdiscountprinted, bbp.isemployee AS bill_bp_isemployee, bbp.ismanufacturer AS bill_bp_ismanufacturer, bbp.isonetime AS bill_bp_isonetime, bbp.ispotaxexempt AS bill_bp_ispotaxexempt, bbp.isprospect AS bill_bp_isprospect, bbp.issalesrep AS bill_bp_issalesrep, bbp.issummary AS bill_bp_issummary, bbp.istaxexempt AS bill_bp_istaxexempt, bbp.isvendor AS bill_bp_isvendor, bbp.logo_id AS Bill_BP_Logo_ID, bbp.m_discountschema_id AS Bill_BP_M_DiscountSchema_ID, bbp.m_pricelist_id AS Bill_BP_M_PriceList_ID, bbp.naics AS bill_bp_naics,
bbp.numberemployees AS bill_bp_numberemployees, bbp.paymentrule AS bill_bp_paymentrule, bbp.paymentrulepo AS bill_bp_paymentrulepo, bbp.po_discountschema_id AS Bill_BP_PO_DiscountSchema_ID, bbp.po_paymentterm_id AS Bill_BP_PO_PaymentTerm_ID, bbp.po_pricelist_id AS Bill_BP_PO_PriceList_ID, bbp.poreference AS bill_bp_poreference, bbp.potentiallifetimevalue AS bill_bp_potentiallifetimevalue, bbp.rating AS bill_bp_rating, bbp.referenceno AS bill_bp_referenceno, bbp.salesrep_id AS Bill_BP_SalesRep_ID, bbp.salesvolume AS bill_bp_salesvolume, bbp.sendemail AS bill_bp_sendemail, bbp.shareofcustomer AS bill_bp_shareofcustomer, bbp.shelflifeminpct AS bill_bp_shelflifeminpct, bbp.so_creditlimit AS bill_bp_so_creditlimit, bbp.socreditstatus AS bill_bp_socreditstatus, bbp.so_creditused AS bill_bp_so_creditused, bbp.so_description AS bill_bp_so_description, bbp.totalopenbalance AS bill_bp_totalopenbalance, bbp.updated AS bill_bp_updated, bbp.updatedby AS Bill_BP_UpdatedBy, bbp.url AS bill_bp_url, bbpl.ad_org_id AS Bill_BP_Location_AD_Org_ID, bbpl.c_bpartner_id AS Bill_BP_Location_C_BPartner_ID, bbpl.created AS bill_bp_location_created, bbpl.createdby AS Bill_BP_Location_CreatedBy, bbpl.c_salesregion_id AS Bill_BP_Location_C_SalesReg_ID, bbpl.fax AS bill_bp_location_fax, bbpl.isactive AS bill_bp_location_isactive, bbpl.isbillto AS bill_bp_location_isbillto, bbpl.isdn AS bill_bp_location_isdn, bbpl.ispayfrom AS bill_bp_location_ispayfrom, bbpl.isremitto AS bill_bp_location_isremitto, bbpl.isshipto AS bill_bp_location_isshipto, bbpl.name AS bill_bp_location_name, bbpl.phone AS bill_bp_location_phone, bbpl.phone2 AS bill_bp_location_phone2, bbpl.updated AS bill_bp_location_updated, bbpl.updatedby AS Bill_BP_Location_UpdatedBy, bbpc.ad_org_id AS Bill_User_AD_Org_ID, bbpc.ad_orgtrx_id AS Bill_User_AD_OrgTrx_ID, bbpc.birthday AS bill_user_ad_birthday, bbpc.c_bpartner_id AS Bill_User_C_BPartner_ID, bbpc.c_bpartner_location_id AS Bill_User_C_BP_Location_ID, bbpc.c_greeting_id AS Bill_User_C_Greeting_ID, bbpc.comments AS bill_user_comments, bbpc.created AS bill_user_created, bbpc.createdby AS Bill_User_CreatedBy, bbpc.description AS bill_user_description, bbpc.email AS bill_user_email, bbpc.fax AS bill_user_fax, bbpc.isactive AS bill_user_isactive, bbpc.lastcontact AS bill_user_lastcontact, bbpc.lastresult AS bill_user_lastresult, bbpc.phone2 AS bill_user_phone2, bbpc.supervisor_id AS Bill_User_Supervisor_ID,
bbpc.updated AS bill_user_updated, bbpc.updatedby AS Bill_User_UpdatedBy, bbpc.value AS bill_user_value, cur.cursymbol AS CurSymbol, cur.description AS cur_description FROM c_order o
JOIN c_doctype_trl dt ON o.c_doctype_id = dt.c_doctype_id
JOIN m_warehouse wh ON o.m_warehouse_id = wh.m_warehouse_id
JOIN c_paymentterm pt ON o.c_paymentterm_id = pt.c_paymentterm_id
JOIN c_paymentterm_trl ptt ON o.c_paymentterm_id = ptt.c_paymentterm_id AND dt.ad_language = ptt.ad_language
JOIN c_bpartner bp ON o.c_bpartner_id = bp.c_bpartner_id
LEFT JOIN c_greeting bpg ON bp.c_greeting_id = bpg.c_greeting_id
LEFT JOIN c_greeting_trl bpgt ON bp.c_greeting_id = bpgt.c_greeting_id AND dt.ad_language = bpgt.ad_language
JOIN c_bpartner_location bpl ON o.c_bpartner_location_id = bpl.c_bpartner_location_id
JOIN c_location l ON bpl.c_location_id = l.c_location_id
LEFT JOIN ad_user bpc ON o.ad_user_id = bpc.ad_user_id
LEFT JOIN c_greeting bpcg ON bpc.c_greeting_id = bpcg.c_greeting_id
LEFT JOIN c_greeting_trl bpcgt ON bpc.c_greeting_id = bpcgt.c_greeting_id AND dt.ad_language = bpcgt.ad_language
JOIN ad_orginfo oi ON o.ad_org_id = oi.ad_org_id
JOIN ad_clientinfo ci ON o.ad_client_id = ci.ad_client_id
LEFT JOIN ad_user u ON o.salesrep_id = u.ad_user_id
LEFT JOIN c_bpartner ubp ON u.c_bpartner_id = ubp.c_bpartner_id
JOIN c_bpartner bbp ON o.bill_bpartner_id = bbp.c_bpartner_id
JOIN c_bpartner_location bbpl ON o.bill_location_id = bbpl.c_bpartner_location_id
LEFT JOIN ad_user bbpc ON o.bill_user_id = bbpc.ad_user_id
LEFT JOIN c_currency_trl cur ON o.c_currency_id = cur.c_currency_id AND dt.ad_language = cur.ad_language
;
-- Feb 15, 2022, 8:09:18 PM CET
UPDATE AD_ViewColumn SET ColumnSQL='COALESCE(l.postal,'''') || COALESCE(l.postal_add,'''')',Updated=TO_DATE('2022-02-15 20:09:18','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_ViewColumn_ID=210292
;
-- Feb 15, 2022, 8:09:26 PM CET
CREATE OR REPLACE VIEW DD_Order_Header_v(AD_Client_ID, AD_Org_ID, IsActive, Created, CreatedBy, Updated, UpdatedBy, AD_Language, DD_Order_ID, C_Order_ID, IsSOTrx, DocumentNo, DocStatus, C_DocType_ID, C_BPartner_ID, BPValue, BPTaxID, NAICS, DUNS, Org_Location_ID, TaxID, M_Warehouse_ID, Warehouse_Location_ID, DocumentType, DocumentTypeNote, SalesRep_ID, SalesRep_Name, DateOrdered, DatePromised, BPGreeting, Name, Name2, BPContactGreeting, Title, Phone, ContactName, C_Location_ID, Postal, ReferenceNo, Description, POReference, C_Charge_ID, ChargeAmt, Volume, Weight, C_Campaign_ID, C_Project_ID, C_Activity_ID, M_Shipper_ID, DeliveryRule, DeliveryViaRule, PriorityRule, Logo_ID) AS SELECT o.ad_client_id AS AD_Client_ID, o.ad_org_id AS AD_Org_ID, o.isactive AS IsActive, o.created AS Created, o.createdby AS CreatedBy, o.updated AS Updated, o.updatedby AS UpdatedBy, CAST('en_US' AS CHARACTER VARYING(6)) AS AD_Language, o.dd_order_id AS DD_Order_ID, o.c_order_id AS C_Order_ID, o.issotrx AS IsSOTrx, o.documentno AS DocumentNo, o.docstatus AS DocStatus, o.c_doctype_id AS C_DocType_ID, o.c_bpartner_id AS C_BPartner_ID, bp.value AS BPValue, bp.taxid AS BPTaxID, bp.naics AS NAICS, bp.duns AS DUNS, oi.c_location_id AS Org_Location_ID, oi.taxid AS TaxID, o.m_warehouse_id AS M_Warehouse_ID, wh.c_location_id AS Warehouse_Location_ID, dt.printname AS DocumentType, dt.documentnote AS DocumentTypeNote, o.salesrep_id AS SalesRep_ID, COALESCE(ubp.name, u.name) AS SalesRep_Name, o.dateordered AS DateOrdered, o.datepromised AS DatePromised, bpg.greeting AS BPGreeting, bp.name AS Name, bp.name2 AS Name2, bpcg.greeting AS BPContactGreeting, bpc.title AS Title, bpc.phone AS Phone, NULLIF(bpc.name, bp.name) AS ContactName, bpl.c_location_id AS C_Location_ID, COALESCE(l.postal,'') || COALESCE(l.postal_add,'') AS Postal, bp.referenceno AS ReferenceNo, o.description AS Description, o.poreference AS POReference, o.c_charge_id AS C_Charge_ID, o.chargeamt AS ChargeAmt, o.volume AS Volume, o.weight AS Weight, o.c_campaign_id AS C_Campaign_ID, o.c_project_id AS C_Project_ID, o.c_activity_id AS C_Activity_ID, o.m_shipper_id AS M_Shipper_ID, o.deliveryrule AS DeliveryRule, o.deliveryviarule AS DeliveryViaRule, o.priorityrule AS PriorityRule, COALESCE(oi.logo_id, ci.logo_id) AS Logo_ID FROM dd_order o
JOIN c_doctype dt ON o.c_doctype_id = dt.c_doctype_id
JOIN m_warehouse wh ON o.m_warehouse_id = wh.m_warehouse_id
JOIN c_bpartner bp ON o.c_bpartner_id = bp.c_bpartner_id
LEFT JOIN c_greeting bpg ON bp.c_greeting_id = bpg.c_greeting_id
JOIN c_bpartner_location bpl ON o.c_bpartner_location_id = bpl.c_bpartner_location_id
JOIN c_location l ON bpl.c_location_id = l.c_location_id
LEFT JOIN ad_user bpc ON o.ad_user_id = bpc.ad_user_id
LEFT JOIN c_greeting bpcg ON bpc.c_greeting_id = bpcg.c_greeting_id
JOIN ad_orginfo oi ON o.ad_org_id = oi.ad_org_id
JOIN ad_clientinfo ci ON o.ad_client_id = ci.ad_client_id
LEFT JOIN ad_user u ON o.salesrep_id = u.ad_user_id
LEFT JOIN c_bpartner ubp ON u.c_bpartner_id = ubp.c_bpartner_id
;
-- Feb 15, 2022, 8:10:29 PM CET
UPDATE AD_ViewColumn SET ColumnSQL='COALESCE(l.postal,'''') || COALESCE(l.postal_add,'''')',Updated=TO_DATE('2022-02-15 20:10:29','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_ViewColumn_ID=210345
;
-- Feb 15, 2022, 8:10:44 PM CET
CREATE OR REPLACE VIEW DD_Order_Header_vt(AD_Client_ID, AD_Org_ID, IsActive, Created, CreatedBy, Updated, UpdatedBy, AD_Language, DD_Order_ID, C_Order_ID, IsSOTrx, DocumentNo, DocStatus, C_DocType_ID, C_BPartner_ID, BPValue, BPTaxID, NAICS, DUNS, Org_Location_ID, TaxID, M_Warehouse_ID, Warehouse_Location_ID, DocumentType, DocumentTypeNote, SalesRep_ID, SalesRep_Name, DateOrdered, DatePromised, BPGreeting, Name, Name2, BPContactGreeting, Title, Phone, ContactName, C_Location_ID, Postal, ReferenceNo, Description, POReference, C_Charge_ID, ChargeAmt, Volume, Weight, C_Campaign_ID, C_Project_ID, C_Activity_ID, M_Shipper_ID, DeliveryRule, DeliveryViaRule, PriorityRule, Logo_ID) AS SELECT o.ad_client_id AS AD_Client_ID, o.ad_org_id AS AD_Org_ID, o.isactive AS IsActive, o.created AS Created, o.createdby AS CreatedBy, o.updated AS Updated, o.updatedby AS UpdatedBy, dt.ad_language AS AD_Language, o.dd_order_id AS DD_Order_ID, o.c_order_id AS C_Order_ID, o.issotrx AS IsSOTrx, o.documentno AS DocumentNo, o.docstatus AS DocStatus, o.c_doctype_id AS C_DocType_ID, o.c_bpartner_id AS C_BPartner_ID, bp.value AS BPValue, bp.taxid AS BPTaxID, bp.naics AS NAICS, bp.duns AS DUNS, oi.c_location_id AS Org_Location_ID, oi.taxid AS TaxID, o.m_warehouse_id AS M_Warehouse_ID, wh.c_location_id AS Warehouse_Location_ID, dt.printname AS DocumentType, dt.documentnote AS DocumentTypeNote, o.salesrep_id AS SalesRep_ID, COALESCE(ubp.name, u.name) AS SalesRep_Name, o.dateordered AS DateOrdered, o.datepromised AS DatePromised, bpg.greeting AS BPGreeting, bp.name AS Name, bp.name2 AS Name2, bpcg.greeting AS BPContactGreeting, bpc.title AS Title, bpc.phone AS Phone, NULLIF(bpc.name, bp.name) AS ContactName, bpl.c_location_id AS C_Location_ID, COALESCE(l.postal,'') || COALESCE(l.postal_add,'') AS Postal, bp.referenceno AS ReferenceNo, o.description AS Description, o.poreference AS POReference, o.c_charge_id AS C_Charge_ID, o.chargeamt AS ChargeAmt, o.volume AS Volume, o.weight AS Weight, o.c_campaign_id AS C_Campaign_ID, o.c_project_id AS C_Project_ID, o.c_activity_id AS C_Activity_ID, o.m_shipper_id AS M_Shipper_ID, o.deliveryrule AS DeliveryRule, o.deliveryviarule AS DeliveryViaRule, o.priorityrule AS PriorityRule, COALESCE(oi.logo_id, ci.logo_id) AS Logo_ID FROM dd_order o
JOIN c_doctype_trl dt ON o.c_doctype_id = dt.c_doctype_id
JOIN m_warehouse wh ON o.m_warehouse_id = wh.m_warehouse_id
JOIN c_bpartner bp ON o.c_bpartner_id = bp.c_bpartner_id
LEFT JOIN c_greeting_trl bpg ON bp.c_greeting_id = bpg.c_greeting_id AND dt.ad_language = bpg.ad_language
JOIN c_bpartner_location bpl ON o.c_bpartner_location_id = bpl.c_bpartner_location_id
JOIN c_location l ON bpl.c_location_id = l.c_location_id
LEFT JOIN ad_user bpc ON o.ad_user_id = bpc.ad_user_id
LEFT JOIN c_greeting_trl bpcg ON bpc.c_greeting_id = bpcg.c_greeting_id AND dt.ad_language = bpcg.ad_language
JOIN ad_orginfo oi ON o.ad_org_id = oi.ad_org_id
JOIN ad_clientinfo ci ON o.ad_client_id = ci.ad_client_id
LEFT JOIN ad_user u ON o.salesrep_id = u.ad_user_id
LEFT JOIN c_bpartner ubp ON u.c_bpartner_id = ubp.c_bpartner_id
;
-- Feb 15, 2022, 8:12:52 PM CET
UPDATE AD_ViewColumn SET ColumnSQL='COALESCE(l.postal,'''') || COALESCE(l.postal_add,'''')',Updated=TO_DATE('2022-02-15 20:12:52','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_ViewColumn_ID=210579
;
-- Feb 15, 2022, 8:13:04 PM CET
CREATE OR REPLACE VIEW M_InOut_Header_v(AD_Client_ID, AD_Org_ID, IsActive, Created, CreatedBy, Updated, UpdatedBy, AD_Language, M_InOut_ID, IsSOTrx, DocumentNo, DocStatus, C_DocType_ID, C_BPartner_ID, BPValue, BPTaxID, NAICS, DUNS, Org_Location_ID, TaxID, M_Warehouse_ID, Warehouse_Location_ID, DocumentType, DocumentTypeNote, C_Order_ID, MovementDate, MovementType, BPGreeting, Name, Name2, BPContactGreeting, Title, Phone, ContactName, C_Location_ID, Postal, ReferenceNo, Description, POReference, DateOrdered, Volume, Weight, M_Shipper_ID, DeliveryRule, DeliveryViaRule, PriorityRule, Logo_ID, AD_OrgTrx_ID, AD_User_ID, C_Activity_ID, C_BPartner_Location_ID, C_Campaign_ID, C_Charge_ID, ChargeAmt, C_Invoice_ID, C_Project_ID, CreateConfirm, CreateFrom, CreatePackage, DateAcct, DatePrinted, DateReceived, DocAction, DropShip_BPartner_ID, DropShip_Location_ID, DropShip_User_ID, FreightAmt, FreightCostRule, GenerateTo, IsApproved, IsDropShip, IsInDispute, m_inout_isintransit, IsPrinted, M_RMA_ID, NoPackages, PickDate, Posted, Processed, ProcessedOn, Processing, Ref_InOut_ID, Reversal_ID, M_InOut_SalesRep_ID, SendEMail, ShipDate, TrackingNo, User1_ID, User2_ID, c_bp_acqusitioncost, c_bp_actuallifetimevalue, c_bp_ad_language, C_BP_AD_OrgBP_ID, C_BP_AD_Org_ID, C_BP_BPartner_Parent_ID, C_BP_C_BP_Group_ID, C_BP_C_Dunning_ID, C_BP_C_Greeting_ID, C_BP_C_InvoiceSchedule_ID, C_BP_C_PaymentTerm_ID, c_bp_created, C_BP_CreatedBy, C_BP_C_TaxGroup_ID, c_bp_deliveryrule, c_bp_deliveryviarule, c_bp_description, c_bp_dunninggrace, c_bp_firstsale, c_bp_flatdiscount, c_bp_freightcostrule, c_bp_invoicerule, c_bp_isactive, c_bp_iscustomer, c_bp_isdiscountprinted, c_bp_isemployee, c_bp_ismanufacturer, c_bp_isonetime, c_bp_ispotaxexempt, c_bp_isprospect, c_bp_issalesrep, c_bp_issummary, c_bp_istaxexempt, c_bp_isvendor, C_BP_Logo_ID, C_BP_M_DiscountSchema_ID, C_BP_M_PriceList_ID, c_bp_numberemployees, c_bp_paymentrule, c_bp_paymentrulepo, C_BP_PO_DiscountSchema_ID, C_BP_PO_PaymentTerm_ID, C_BP_PO_PriceList_ID, c_bp_poreference, c_bp_potentiallifetimevalue, c_bp_rating, C_BP_SalesRep_ID, c_bp_salesvolume, c_bp_sendemail, c_bp_shareofcustomer, c_bp_shelflifeminpct, c_bp_so_creditlimit, c_bp_socreditstatus, c_bp_so_creditused, c_bp_so_description, c_bp_totalopenbalance, c_bp_updated, C_BP_UpdatedBy, c_bp_url, C_Greeting_AD_Org_ID, c_greeting_isactive, IsFirstNameOnly, c_greeting_name, C_BP_Location_AD_Org_ID,
C_BP_Location_C_BPartner_ID, c_bp_location_created, C_BP_Location_CreatedBy, C_SalesRegion_ID, c_bp_location_fax, c_bp_location_isactive, IsBillTo, ISDN, IsPayFrom, IsRemitTo, IsShipTo, c_bp_location_name, c_bp_location_phone, c_bp_location_phone2, c_bp_location_updated, C_BP_Location_UpdatedBy, Address1, Address2, Address3, Address4, C_Location_AD_Org_ID, C_City_ID, C_Country_ID, City, c_location_created, C_Location_CreatedBy, C_Region_ID, c_location_isactive, RegionName, c_location_updated, C_Location_UpdatedBy, AD_User_AD_Org_ID, AD_User_AD_AD_OrgTrx_ID, ad_user_ad_birthday, AD_User_C_BPartner_ID, AD_User_C_BPartner_Location_ID, AD_User_C_Greeting_ID, ad_user_comments, ad_user_created, AD_User_CreatedBy, ad_user_description, ad_user_email, ad_user_fax, ad_user_isactive, ad_user_lastcontact, ad_user_lastresult, ad_user_phone2, AD_User_Supervisor_ID, ad_user_updated, AD_User_UpdatedBy, ad_user_value, C_User_Greeting_AD_Org_ID, c_user_greeting_isactive, c_user_greeting_isfnameonly, c_user_greeting_name, AD_OrgInfo_AD_Org_ID, AD_OrgType_ID, C_Calendar_ID, ad_orginfo_created, AD_OrgInfo_CreatedBy, DropShip_Warehouse_ID, ad_orginfo_duns, ad_orginfo_email, ad_orginfo_fax, ad_orginfo_isactive, AD_OrgInfo_M_Warehouse_ID, Parent_Org_ID, ad_orginfo_phone, ad_orginfo_phone2, ReceiptFooterMsg, Supervisor_ID, ad_orginfo_updated, AD_OrgInfo_UpdatedBy, M_Warehouse_AD_Org_ID, m_warehouse_description, m_warehouse__isactive, IsDisallowNegativeInv, m_warehouse_isintransit, M_WarehouseSource_ID, m_warehouse_name, ReplenishmentClass, Separator, m_warehouse_value) AS SELECT io.ad_client_id AS AD_Client_ID, io.ad_org_id AS AD_Org_ID, io.isactive AS IsActive, io.created AS Created, io.createdby AS CreatedBy, io.updated AS Updated, io.updatedby AS UpdatedBy, CAST('en_US' AS CHARACTER VARYING(6)) AS AD_Language, io.m_inout_id AS M_InOut_ID, io.issotrx AS IsSOTrx, io.documentno AS DocumentNo, io.docstatus AS DocStatus, io.c_doctype_id AS C_DocType_ID, io.c_bpartner_id AS C_BPartner_ID, bp.value AS BPValue, bp.taxid AS BPTaxID, bp.naics AS NAICS, bp.duns AS DUNS, oi.c_location_id AS Org_Location_ID, oi.taxid AS TaxID, io.m_warehouse_id AS M_Warehouse_ID, wh.c_location_id AS Warehouse_Location_ID, dt.printname AS DocumentType, dt.documentnote AS DocumentTypeNote, io.c_order_id AS C_Order_ID, io.movementdate AS MovementDate, io.movementtype AS MovementType, bpg.greeting AS BPGreeting, bp.name AS Name,
bp.name2 AS Name2, bpcg.greeting AS BPContactGreeting, bpc.title AS Title, bpc.phone AS Phone, NULLIF(bpc.name, bp.name) AS ContactName, bpl.c_location_id AS C_Location_ID, COALESCE(l.postal,'') || COALESCE(l.postal_add,'') AS Postal, bp.referenceno AS ReferenceNo, io.description AS Description, io.poreference AS POReference, io.dateordered AS DateOrdered, io.volume AS Volume, io.weight AS Weight, io.m_shipper_id AS M_Shipper_ID, io.deliveryrule AS DeliveryRule, io.deliveryviarule AS DeliveryViaRule, io.priorityrule AS PriorityRule, COALESCE(oi.logo_id, ci.logo_id) AS Logo_ID, io.ad_orgtrx_id AS AD_OrgTrx_ID, io.ad_user_id AS AD_User_ID, io.c_activity_id AS C_Activity_ID, io.c_bpartner_location_id AS C_BPartner_Location_ID, io.c_campaign_id AS C_Campaign_ID, io.c_charge_id AS C_Charge_ID, io.chargeamt AS ChargeAmt, io.c_invoice_id AS C_Invoice_ID, io.c_project_id AS C_Project_ID, io.createconfirm AS CreateConfirm, io.createfrom AS CreateFrom, io.createpackage AS CreatePackage, io.dateacct AS DateAcct, io.dateprinted AS DatePrinted, io.datereceived AS DateReceived, io.docaction AS DocAction, io.dropship_bpartner_id AS DropShip_BPartner_ID, io.dropship_location_id AS DropShip_Location_ID, io.dropship_user_id AS DropShip_User_ID, io.freightamt AS FreightAmt, io.freightcostrule AS FreightCostRule, io.generateto AS GenerateTo, io.isapproved AS IsApproved, io.isdropship AS IsDropShip, io.isindispute AS IsInDispute, io.isintransit AS m_inout_isintransit, io.isprinted AS IsPrinted, io.m_rma_id AS M_RMA_ID, io.nopackages AS NoPackages, io.pickdate AS PickDate, io.posted AS Posted, io.processed AS Processed, io.processedon AS ProcessedOn, io.processing AS Processing, io.ref_inout_id AS Ref_InOut_ID, io.reversal_id AS Reversal_ID, io.salesrep_id AS M_InOut_SalesRep_ID, io.sendemail AS SendEMail, io.shipdate AS ShipDate, io.trackingno AS TrackingNo, io.user1_id AS User1_ID, io.user2_id AS 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.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.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.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.totalopenbalance AS c_bp_totalopenbalance, bp.updated AS c_bp_updated, bp.updatedby AS C_BP_UpdatedBy, bp.url AS c_bp_url, bpg.ad_org_id AS C_Greeting_AD_Org_ID, bpg.isactive AS c_greeting_isactive, bpg.isfirstnameonly AS IsFirstNameOnly, bpg.name AS c_greeting_name, bpl.ad_org_id AS C_BP_Location_AD_Org_ID, bpl.c_bpartner_id AS C_BP_Location_C_BPartner_ID, bpl.created AS c_bp_location_created, bpl.createdby AS C_BP_Location_CreatedBy, bpl.c_salesregion_id AS C_SalesRegion_ID, bpl.fax AS c_bp_location_fax, bpl.isactive AS c_bp_location_isactive, bpl.isbillto AS IsBillTo, bpl.isdn AS ISDN, bpl.ispayfrom AS IsPayFrom, bpl.isremitto AS IsRemitTo, bpl.isshipto AS 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, l.address1 AS Address1, l.address2 AS Address2, l.address3 AS Address3, l.address4 AS Address4, l.ad_org_id AS C_Location_AD_Org_ID, l.c_city_id AS C_City_ID, l.c_country_id AS C_Country_ID, l.city AS City, l.created AS c_location_created, l.createdby AS C_Location_CreatedBy, l.c_region_id AS C_Region_ID, l.isactive AS c_location_isactive, l.regionname AS RegionName, l.updated AS c_location_updated, l.updatedby AS C_Location_UpdatedBy, bpc.ad_org_id AS AD_User_AD_Org_ID, bpc.ad_orgtrx_id AS AD_User_AD_AD_OrgTrx_ID, bpc.birthday AS ad_user_ad_birthday, bpc.c_bpartner_id AS AD_User_C_BPartner_ID, bpc.c_bpartner_location_id AS AD_User_C_BPartner_Location_ID, bpc.c_greeting_id AS AD_User_C_Greeting_ID, bpc.comments AS ad_user_comments, bpc.created AS ad_user_created, bpc.createdby AS AD_User_CreatedBy, bpc.description AS ad_user_description, bpc.email AS ad_user_email, bpc.fax AS ad_user_fax, bpc.isactive AS ad_user_isactive, bpc.lastcontact AS ad_user_lastcontact, bpc.lastresult AS ad_user_lastresult, bpc.phone2 AS ad_user_phone2, bpc.supervisor_id AS AD_User_Supervisor_ID, bpc.updated AS ad_user_updated, bpc.updatedby AS AD_User_UpdatedBy, bpc.value AS ad_user_value, bpcg.ad_org_id AS C_User_Greeting_AD_Org_ID, bpcg.isactive AS c_user_greeting_isactive, bpcg.isfirstnameonly AS c_user_greeting_isfnameonly, bpcg.name AS c_user_greeting_name, oi.ad_org_id AS AD_OrgInfo_AD_Org_ID, oi.ad_orgtype_id AS AD_OrgType_ID, oi.c_calendar_id AS C_Calendar_ID, oi.created AS ad_orginfo_created, oi.createdby AS AD_OrgInfo_CreatedBy, oi.dropship_warehouse_id AS DropShip_Warehouse_ID, oi.duns AS ad_orginfo_duns, oi.email AS ad_orginfo_email, oi.fax AS ad_orginfo_fax, oi.isactive AS ad_orginfo_isactive, oi.m_warehouse_id AS AD_OrgInfo_M_Warehouse_ID, oi.parent_org_id AS Parent_Org_ID, oi.phone AS ad_orginfo_phone, oi.phone2 AS ad_orginfo_phone2, oi.receiptfootermsg AS ReceiptFooterMsg, oi.supervisor_id AS Supervisor_ID, oi.updated AS ad_orginfo_updated, oi.updatedby AS AD_OrgInfo_UpdatedBy, wh.ad_org_id AS M_Warehouse_AD_Org_ID, wh.description AS m_warehouse_description, wh.isactive AS m_warehouse__isactive, wh.isdisallownegativeinv AS IsDisallowNegativeInv, wh.isintransit AS m_warehouse_isintransit, wh.m_warehousesource_id AS M_WarehouseSource_ID, wh.name AS m_warehouse_name,
wh.replenishmentclass AS ReplenishmentClass, wh.separator AS Separator, wh.value AS m_warehouse_value FROM m_inout io
JOIN c_doctype dt ON io.c_doctype_id = dt.c_doctype_id
JOIN c_bpartner bp ON io.c_bpartner_id = bp.c_bpartner_id
LEFT JOIN c_greeting bpg ON bp.c_greeting_id = bpg.c_greeting_id
JOIN c_bpartner_location bpl ON io.c_bpartner_location_id = bpl.c_bpartner_location_id
JOIN c_location l ON bpl.c_location_id = l.c_location_id
LEFT JOIN ad_user bpc ON io.ad_user_id = bpc.ad_user_id
LEFT JOIN c_greeting bpcg ON bpc.c_greeting_id = bpcg.c_greeting_id
JOIN ad_orginfo oi ON io.ad_org_id = oi.ad_org_id
JOIN ad_clientinfo ci ON io.ad_client_id = ci.ad_client_id
JOIN m_warehouse wh ON io.m_warehouse_id = wh.m_warehouse_id
;
-- Feb 15, 2022, 8:14:56 PM CET
UPDATE AD_ViewColumn SET ColumnSQL='COALESCE(l.postal,'''') || COALESCE(l.postal_add,'''')',Updated=TO_DATE('2022-02-15 20:14:56','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_ViewColumn_ID=210815
;
-- Feb 15, 2022, 8:15:11 PM CET
CREATE OR REPLACE VIEW M_InOut_Header_vt(AD_Client_ID, AD_Org_ID, IsActive, Created, CreatedBy, Updated, UpdatedBy, AD_Language, M_InOut_ID, IsSOTrx, DocumentNo, DocStatus, C_DocType_ID, C_BPartner_ID, BPValue, BPTaxID, NAICS, DUNS, Org_Location_ID, TaxID, M_Warehouse_ID, Warehouse_Location_ID, DocumentType, DocumentTypeNote, C_Order_ID, MovementDate, MovementType, BPGreeting, Name, Name2, BPContactGreeting, Title, Phone, ContactName, C_Location_ID, Postal, ReferenceNo, Description, POReference, DateOrdered, Volume, Weight, M_Shipper_ID, DeliveryRule, DeliveryViaRule, PriorityRule, Logo_ID, AD_OrgTrx_ID, AD_User_ID, C_Activity_ID, C_BPartner_Location_ID, C_Campaign_ID, C_Charge_ID, ChargeAmt, C_Invoice_ID, C_Project_ID, CreateConfirm, CreateFrom, CreatePackage, DateAcct, DatePrinted, DateReceived, DocAction, DropShip_BPartner_ID, DropShip_Location_ID, DropShip_User_ID, FreightAmt, FreightCostRule, GenerateTo, IsApproved, IsDropShip, IsInDispute, m_inout_isintransit, IsPrinted, M_RMA_ID, NoPackages, PickDate, Posted, Processed, ProcessedOn, Processing, Ref_InOut_ID, Reversal_ID, M_InOut_SalesRep_ID, SendEMail, ShipDate, TrackingNo, User1_ID, User2_ID, c_bp_acqusitioncost, c_bp_actuallifetimevalue, c_bp_ad_language, C_BP_AD_OrgBP_ID, C_BP_AD_Org_ID, C_BP_BPartner_Parent_ID, C_BP_C_BP_Group_ID, C_BP_C_Dunning_ID, C_BP_C_Greeting_ID, C_BP_C_InvoiceSchedule_ID, C_BP_C_PaymentTerm_ID, c_bp_created, C_BP_CreatedBy, C_BP_C_TaxGroup_ID, c_bp_deliveryrule, c_bp_deliveryviarule, c_bp_description, c_bp_dunninggrace, c_bp_firstsale, c_bp_flatdiscount, c_bp_freightcostrule, c_bp_invoicerule, c_bp_isactive, c_bp_iscustomer, c_bp_isdiscountprinted, c_bp_isemployee, c_bp_ismanufacturer, c_bp_isonetime, c_bp_ispotaxexempt, c_bp_isprospect, c_bp_issalesrep, c_bp_issummary, c_bp_istaxexempt, c_bp_isvendor, C_BP_Logo_ID, C_BP_M_DiscountSchema_ID, C_BP_M_PriceList_ID, c_bp_numberemployees, c_bp_paymentrule, c_bp_paymentrulepo, C_BP_PO_DiscountSchema_ID, C_BP_PO_PaymentTerm_ID, C_BP_PO_PriceList_ID, c_bp_poreference, c_bp_potentiallifetimevalue, c_bp_rating, C_BP_SalesRep_ID, c_bp_salesvolume, c_bp_sendemail, c_bp_shareofcustomer, c_bp_shelflifeminpct, c_bp_so_creditlimit, c_bp_socreditstatus, c_bp_so_creditused, c_bp_so_description, c_bp_totalopenbalance, c_bp_updated, C_BP_UpdatedBy, c_bp_url, C_Greeting_AD_Org_ID, c_greeting_isactive, IsFirstNameOnly, c_greeting_name, C_BP_Location_AD_Org_ID,
C_BP_Location_C_BPartner_ID, c_bp_location_created, C_BP_Location_CreatedBy, C_SalesRegion_ID, c_bp_location_fax, c_bp_location_isactive, IsBillTo, ISDN, IsPayFrom, IsRemitTo, IsShipTo, c_bp_location_name, c_bp_location_phone, c_bp_location_phone2, c_bp_location_updated, C_BP_Location_UpdatedBy, Address1, Address2, Address3, Address4, C_Location_AD_Org_ID, C_City_ID, C_Country_ID, City, c_location_created, C_Location_CreatedBy, C_Region_ID, c_location_isactive, RegionName, c_location_updated, C_Location_UpdatedBy, AD_User_AD_Org_ID, AD_User_AD_AD_OrgTrx_ID, ad_user_ad_birthday, AD_User_C_BPartner_ID, AD_User_C_BPartner_Location_ID, AD_User_C_Greeting_ID, ad_user_comments, ad_user_created, AD_User_CreatedBy, ad_user_description, ad_user_email, ad_user_fax, ad_user_isactive, ad_user_lastcontact, ad_user_lastresult, ad_user_phone2, AD_User_Supervisor_ID, ad_user_updated, AD_User_UpdatedBy, ad_user_value, C_User_Greeting_AD_Org_ID, c_user_greeting_isactive, c_user_greeting_isfnameonly, c_user_greeting_name, AD_OrgInfo_AD_Org_ID, AD_OrgType_ID, C_Calendar_ID, ad_orginfo_created, AD_OrgInfo_CreatedBy, DropShip_Warehouse_ID, ad_orginfo_duns, ad_orginfo_email, ad_orginfo_fax, ad_orginfo_isactive, AD_OrgInfo_M_Warehouse_ID, Parent_Org_ID, ad_orginfo_phone, ad_orginfo_phone2, ReceiptFooterMsg, Supervisor_ID, ad_orginfo_updated, AD_OrgInfo_UpdatedBy, M_Warehouse_AD_Org_ID, m_warehouse_description, m_warehouse__isactive, IsDisallowNegativeInv, m_warehouse_isintransit, M_WarehouseSource_ID, m_warehouse_name, ReplenishmentClass, Separator, m_warehouse_value) AS SELECT io.ad_client_id AS AD_Client_ID, io.ad_org_id AS AD_Org_ID, io.isactive AS IsActive, io.created AS Created, io.createdby AS CreatedBy, io.updated AS Updated, io.updatedby AS UpdatedBy, dt.ad_language AS AD_Language, io.m_inout_id AS M_InOut_ID, io.issotrx AS IsSOTrx, io.documentno AS DocumentNo, io.docstatus AS DocStatus, io.c_doctype_id AS C_DocType_ID, io.c_bpartner_id AS C_BPartner_ID, bp.value AS BPValue, bp.taxid AS BPTaxID, bp.naics AS NAICS, bp.duns AS DUNS, oi.c_location_id AS Org_Location_ID, oi.taxid AS TaxID, io.m_warehouse_id AS M_Warehouse_ID, wh.c_location_id AS Warehouse_Location_ID, dt.printname AS DocumentType, dt.documentnote AS DocumentTypeNote, io.c_order_id AS C_Order_ID, io.movementdate AS MovementDate, io.movementtype AS MovementType, bpgt.greeting AS BPGreeting, bp.name AS Name, bp.name2 AS Name2,
bpcgt.greeting AS BPContactGreeting, bpc.title AS Title, bpc.phone AS Phone, NULLIF(bpc.name, bp.name) AS ContactName, bpl.c_location_id AS C_Location_ID, COALESCE(l.postal,'') || COALESCE(l.postal_add,'') AS Postal, bp.referenceno AS ReferenceNo, io.description AS Description, io.poreference AS POReference, io.dateordered AS DateOrdered, io.volume AS Volume, io.weight AS Weight, io.m_shipper_id AS M_Shipper_ID, io.deliveryrule AS DeliveryRule, io.deliveryviarule AS DeliveryViaRule, io.priorityrule AS PriorityRule, COALESCE(oi.logo_id, ci.logo_id) AS Logo_ID, io.ad_orgtrx_id AS AD_OrgTrx_ID, io.ad_user_id AS AD_User_ID, io.c_activity_id AS C_Activity_ID, io.c_bpartner_location_id AS C_BPartner_Location_ID, io.c_campaign_id AS C_Campaign_ID, io.c_charge_id AS C_Charge_ID, io.chargeamt AS ChargeAmt, io.c_invoice_id AS C_Invoice_ID, io.c_project_id AS C_Project_ID, io.createconfirm AS CreateConfirm, io.createfrom AS CreateFrom, io.createpackage AS CreatePackage, io.dateacct AS DateAcct, io.dateprinted AS DatePrinted, io.datereceived AS DateReceived, io.docaction AS DocAction, io.dropship_bpartner_id AS DropShip_BPartner_ID, io.dropship_location_id AS DropShip_Location_ID, io.dropship_user_id AS DropShip_User_ID, io.freightamt AS FreightAmt, io.freightcostrule AS FreightCostRule, io.generateto AS GenerateTo, io.isapproved AS IsApproved, io.isdropship AS IsDropShip, io.isindispute AS IsInDispute, io.isintransit AS m_inout_isintransit, io.isprinted AS IsPrinted, io.m_rma_id AS M_RMA_ID, io.nopackages AS NoPackages, io.pickdate AS PickDate, io.posted AS Posted, io.processed AS Processed, io.processedon AS ProcessedOn, io.processing AS Processing, io.ref_inout_id AS Ref_InOut_ID, io.reversal_id AS Reversal_ID, io.salesrep_id AS M_InOut_SalesRep_ID, io.sendemail AS SendEMail, io.shipdate AS ShipDate, io.trackingno AS TrackingNo, io.user1_id AS User1_ID, io.user2_id AS 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.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.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.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.totalopenbalance AS c_bp_totalopenbalance, bp.updated AS c_bp_updated, bp.updatedby AS C_BP_UpdatedBy, bp.url AS c_bp_url, bpgt.ad_org_id AS C_Greeting_AD_Org_ID, bpgt.isactive AS c_greeting_isactive, bpg.isfirstnameonly AS IsFirstNameOnly, bpgt.name AS c_greeting_name, bpl.ad_org_id AS C_BP_Location_AD_Org_ID, bpl.c_bpartner_id AS C_BP_Location_C_BPartner_ID, bpl.created AS c_bp_location_created, bpl.createdby AS C_BP_Location_CreatedBy, bpl.c_salesregion_id AS C_SalesRegion_ID, bpl.fax AS c_bp_location_fax, bpl.isactive AS c_bp_location_isactive, bpl.isbillto AS IsBillTo, bpl.isdn AS ISDN, bpl.ispayfrom AS IsPayFrom, bpl.isremitto AS IsRemitTo, bpl.isshipto AS 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, l.address1 AS Address1, l.address2 AS Address2, l.address3 AS Address3, l.address4 AS Address4, l.ad_org_id AS C_Location_AD_Org_ID, l.c_city_id AS C_City_ID, l.c_country_id AS C_Country_ID, l.city AS City, l.created AS c_location_created, l.createdby AS C_Location_CreatedBy, l.c_region_id AS C_Region_ID, l.isactive AS c_location_isactive, l.regionname AS RegionName, l.updated AS c_location_updated, l.updatedby AS C_Location_UpdatedBy, bpc.ad_org_id AS AD_User_AD_Org_ID, bpc.ad_orgtrx_id AS AD_User_AD_AD_OrgTrx_ID, bpc.birthday AS ad_user_ad_birthday, bpc.c_bpartner_id AS AD_User_C_BPartner_ID, bpc.c_bpartner_location_id AS AD_User_C_BPartner_Location_ID, bpc.c_greeting_id AS AD_User_C_Greeting_ID, bpc.comments AS ad_user_comments, bpc.created AS ad_user_created, bpc.createdby AS AD_User_CreatedBy, bpc.description AS ad_user_description, bpc.email AS ad_user_email, bpc.fax AS ad_user_fax, bpc.isactive AS ad_user_isactive, bpc.lastcontact AS ad_user_lastcontact, bpc.lastresult AS ad_user_lastresult, bpc.phone2 AS ad_user_phone2, bpc.supervisor_id AS AD_User_Supervisor_ID, bpc.updated AS ad_user_updated, bpc.updatedby AS AD_User_UpdatedBy, bpc.value AS ad_user_value, bpcgt.ad_org_id AS C_User_Greeting_AD_Org_ID, bpcgt.isactive AS c_user_greeting_isactive, bpcg.isfirstnameonly AS c_user_greeting_isfnameonly, bpcgt.name AS c_user_greeting_name, oi.ad_org_id AS AD_OrgInfo_AD_Org_ID, oi.ad_orgtype_id AS AD_OrgType_ID, oi.c_calendar_id AS C_Calendar_ID, oi.created AS ad_orginfo_created, oi.createdby AS AD_OrgInfo_CreatedBy, oi.dropship_warehouse_id AS DropShip_Warehouse_ID, oi.duns AS ad_orginfo_duns, oi.email AS ad_orginfo_email, oi.fax AS ad_orginfo_fax, oi.isactive AS ad_orginfo_isactive, oi.m_warehouse_id AS AD_OrgInfo_M_Warehouse_ID, oi.parent_org_id AS Parent_Org_ID, oi.phone AS ad_orginfo_phone, oi.phone2 AS ad_orginfo_phone2, oi.receiptfootermsg AS ReceiptFooterMsg, oi.supervisor_id AS Supervisor_ID, oi.updated AS ad_orginfo_updated, oi.updatedby AS AD_OrgInfo_UpdatedBy, wh.ad_org_id AS M_Warehouse_AD_Org_ID, wh.description AS m_warehouse_description, wh.isactive AS m_warehouse__isactive, wh.isdisallownegativeinv AS IsDisallowNegativeInv, wh.isintransit AS m_warehouse_isintransit, wh.m_warehousesource_id AS M_WarehouseSource_ID, wh.name AS m_warehouse_name, wh.replenishmentclass AS ReplenishmentClass,
wh.separator AS Separator, wh.value AS m_warehouse_value FROM m_inout io
JOIN c_doctype_trl dt ON io.c_doctype_id = dt.c_doctype_id
JOIN c_bpartner bp ON io.c_bpartner_id = bp.c_bpartner_id
LEFT JOIN c_greeting bpg ON bp.c_greeting_id = bpg.c_greeting_id
LEFT JOIN c_greeting_trl bpgt ON bp.c_greeting_id = bpgt.c_greeting_id AND dt.ad_language = bpgt.ad_language
JOIN c_bpartner_location bpl ON io.c_bpartner_location_id = bpl.c_bpartner_location_id
JOIN c_location l ON bpl.c_location_id = l.c_location_id
LEFT JOIN ad_user bpc ON io.ad_user_id = bpc.ad_user_id
LEFT JOIN c_greeting bpcg ON bpc.c_greeting_id = bpcg.c_greeting_id
LEFT JOIN c_greeting_trl bpcgt ON bpc.c_greeting_id = bpcgt.c_greeting_id AND dt.ad_language = bpcgt.ad_language
JOIN ad_orginfo oi ON io.ad_org_id = oi.ad_org_id
JOIN ad_clientinfo ci ON io.ad_client_id = ci.ad_client_id
JOIN m_warehouse wh ON io.m_warehouse_id = wh.m_warehouse_id
;
-- Feb 15, 2022, 10:06:47 PM CET
DROP VIEW RV_T_1099Extract
;
-- Feb 15, 2022, 10:08:55 PM CET
CREATE OR REPLACE VIEW RV_T_1099Extract(AD_PInstance_ID, AD_Client_ID, AD_Org_ID, IsActive, Created, CreatedBy, Updated, UpdatedBy, C_BPartner_ID, Value, Name, TaxID, Address, Address1, Address2, Address3, Address4, CityStateZip, City, Region, Zip, Country, Cut_Year, Cut_Date, AmtBucket01, AmtBucket02, AmtBucket03, AmtBucket04, AmtBucket05, AmtBucket06, AmtBucket07, AmtBucket08, AmtBucket09, AmtBucket10, AmtBucket11, AmtBucket12, AmtBucket13, AmtBucket14, AmtBucket15, AmtBucket16) AS SELECT t.ad_pinstance_id AS AD_PInstance_ID, t.ad_client_id AS AD_Client_ID, t.ad_org_id AS AD_Org_ID, t.isactive AS IsActive, t.created AS Created, t.createdby AS CreatedBy, t.updated AS Updated, t.updatedby AS UpdatedBy, t.c_bpartner_id AS C_BPartner_ID, t.value AS Value, t.name AS Name, t.taxid AS TaxID, (((((l.address1 || ' ') || l.address2) || ' ') || l.address3) || ' ') || l.address4 AS Address, l.address1 AS Address1, l.address2 AS Address2, l.address3 AS Address3, l.address4 AS Address4, (((l.city || ', ') || r.name) || ' ') ||COALESCE(l.postal,'') || COALESCE(l.postal_add,'') AS CityStateZip, l.city AS City, r.name AS Region, COALESCE(l.postal,'') || COALESCE(l.postal_add,'') AS Zip, ctry.name AS Country, t.cut_year AS Cut_Year, t.cut_date AS Cut_Date, COALESCE(t.amtbucket01, 0) AS AmtBucket01, COALESCE(t.amtbucket02, 0) AS AmtBucket02, COALESCE(t.amtbucket03, 0) AS AmtBucket03, COALESCE(t.amtbucket04, 0) AS AmtBucket04, COALESCE(t.amtbucket05, 0) AS AmtBucket05, COALESCE(t.amtbucket06, 0) AS AmtBucket06, COALESCE(t.amtbucket07, 0) AS AmtBucket07, COALESCE(t.amtbucket08, 0) AS AmtBucket08, COALESCE(t.amtbucket09, 0) AS AmtBucket09, COALESCE(t.amtbucket10, 0) AS AmtBucket10, COALESCE(t.amtbucket11, 0) AS AmtBucket11, COALESCE(t.amtbucket12, 0) AS AmtBucket12, COALESCE(t.amtbucket13, 0) AS AmtBucket13, COALESCE(t.amtbucket14, 0) AS AmtBucket14, COALESCE(t.amtbucket15, 0) AS AmtBucket15, COALESCE(t.amtbucket16, 0) AS AmtBucket16 FROM t_1099extract t
LEFT JOIN c_location l ON t.c_location_id = l.c_location_id
LEFT JOIN c_region r ON r.c_region_id = l.c_region_id
LEFT JOIN c_country ctry ON ctry.c_country_id = l.c_country_id WHERE t.ad_pinstance_id = (( SELECT max(t_1099extract.ad_pinstance_id) AS max
FROM t_1099extract))
;