-- IDEMPIERE-5057 Implement Deductible and non deductible input tax for purchasing and costing
SELECT register_migration_script('202210281534_IDEMPIERE-5057.sql') FROM dual;

-- Oct 28, 2022, 3:34:01 PM CEST
UPDATE AD_ViewColumn SET ColumnSQL='999998',Updated=TO_TIMESTAMP('2022-10-28 15:34:01','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_ViewColumn_ID=206404
;

-- Oct 28, 2022, 3:34:11 PM CEST
UPDATE AD_ViewColumn SET ColumnSQL='999999',Updated=TO_TIMESTAMP('2022-10-28 15:34:11','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_ViewColumn_ID=206782
;

-- Oct 28, 2022, 3:34:34 PM CEST
UPDATE AD_ViewColumn SET ColumnSQL='999998',Updated=TO_TIMESTAMP('2022-10-28 15:34:34','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_ViewColumn_ID=207916
;

-- Oct 28, 2022, 3:34:42 PM CEST
UPDATE AD_ViewColumn SET ColumnSQL='999999',Updated=TO_TIMESTAMP('2022-10-28 15:34:42','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_ViewColumn_ID=208294
;

-- Oct 28, 2022, 3:35:17 PM CEST
CREATE OR REPLACE VIEW C_Order_LineTax_v(AD_Client_ID, AD_Org_ID, IsActive, Created, CreatedBy, Updated, UpdatedBy, AD_Language, C_Order_ID, C_OrderLine_ID, C_Tax_ID, TaxIndicator, C_BPartner_ID, C_BPartner_Location_ID, BPName, C_Location_ID, Line, M_Product_ID, VendorProductNo, QtyOrdered, QtyEntered, UOMSymbol, Name, Description, DocumentNote, UPC, SKU, ProductValue, ResourceDescription, PriceList, PriceEnteredList, Discount, PriceActual, PriceEntered, LineNetAmt, ProductDescription, ImageURL, C_Campaign_ID, C_Project_ID, C_Activity_ID, C_ProjectPhase_ID, C_ProjectTask_ID, C_OrderLine_AD_OrgTrx_ID, C_OrderLine_C_Charge_ID, C_OrderLine_C_Currency_ID, C_UOM_ID, DateDelivered, DateInvoiced, DateOrdered, c_orderline_datepromised, c_orderline_freightamt, IsDescription, Link_OrderLine_ID, M_Promotion_ID, C_OrderLine_M_Shipper_ID, C_OrderLine_M_Warehouse_ID, PriceCost, PriceLimit, c_orderline_processed, QtyDelivered, QtyInvoiced, QtyLostSales, QtyReserved, Ref_OrderLine_ID, RRAmt, RRStartDate, S_ResourceAssignment_ID, C_OrderLine_User1_ID, C_OrderLine_User2_ID, C_UOM_AD_Org_ID, CostingPrecision, c_uom_description, c_uom_isactive, IsDefault, c_uom_name, StdPrecision, UOMType, X12DE355, C_Order_AD_Org_ID, C_Order_AD_OrgTrx_ID, AD_User_ID, AmountRefunded, AmountTendered, Bill_BPartner_ID, Bill_Location_ID, Bill_User_ID, C_Order_C_Activity_ID, C_Order_C_BPartner_ID, C_Order_C_Campaign_ID, C_CashLine_ID, C_CashPlanLine_ID, C_Order_C_Charge_ID, C_ConversionType_ID, C_Order_C_Currency_ID, C_DocType_ID, C_DocTypeTarget_ID, ChargeAmt, CopyFrom, C_Payment_ID, C_PaymentTerm_ID, C_POS_ID, C_Order_C_Project_ID, c_order_created, C_Order_CreatedBy, DateAcct, DatePrinted, c_order_datepromised, DeliveryRule, DeliveryViaRule, c_order_description, DocAction, DocStatus, DocumentNo, DropShip_BPartner_ID, DropShip_Location_ID, DropShip_User_ID, c_order_freightamt, FreightCostRule, GrandTotal, InvoiceRule, c_order_isactive, IsApproved, IsCreditApproved, IsDelivered, c_order_isdiscountprinted, c_order_isdropship, IsInvoiced, IsPayScheduleValid, IsPrinted, IsSelected, c_order_isselfservice, IsSOTrx, IsTaxIncluded, IsTransferred, Link_Order_ID, C_Order_M_FreightCategory_ID, C_Order_M_PriceList_ID, C_Order_M_Shipper_ID, C_Order_M_Warehouse_ID, OrderType, Pay_BPartner_ID, Pay_Location_ID, c_order_paymentrule, POReference, Posted, PriorityRule, c_order_processed, ProcessedOn, PromotionCode, Ref_Order_ID, SalesRep_ID, c_order_sendemail, TotalLines, c_order_updated, C_Order_UpdatedBy, C_Order_User1_ID, C_Order_User2_ID, c_order_volume, c_order_weight, M_Product_AD_Org_ID, Classification, m_product_copyfrom, m_product_created, M_Product_CreatedBy, C_RevenueRecognition_ID, C_SubscriptionType_ID, C_TaxCategory_ID, M_Product_C_UOM_ID, DescriptionURL, m_product_discontinued, m_product_discontinuedat, Group1, Group2, GuaranteeDays, GuaranteeDaysMin, Help, m_product_isactive, IsBOM, m_product_isdropship, IsExcludeAutoDelivery, IsInvoicePrintDetails, IsPickListPrintDetails, IsPurchased, m_product_isselfservice, IsSold, IsStocked, m_product_issummary, IsVerified, IsWebStoreFeatured, LowLevel, M_AttributeSet_ID, M_AttributeSetInstance_ID, M_Product_M_FreightCategory_ID, M_Locator_ID, M_Product_Product_Category_ID, m_product_processing, ProductType, R_MailText_ID, M_Product_SalesRep_ID, S_ExpenseType_ID, ShelfDepth, ShelfHeight, ShelfWidth, S_Resource_ID, UnitsPerPack, UnitsPerPallet, m_product_updated, M_Product_UpdatedBy, VersionNo, m_product_volume, m_product_weight, M_Product_PO_AD_Org_ID, M_Product_PO_C_BPartner_ID, M_Product_PO_C_Currency_ID, CostPerOrder, m_product_po_created, M_Product_PO_CreatedBy, M_Product_PO_C_UOM_ID, DeliveryTime_Actual, DeliveryTime_Promised, m_product_po_discontinued, m_product_po_discontinuedat, m_product_po_isactive, IsCurrentVendor, m_product_po_manufacturer, M_Product_PO_M_Product_ID, Order_Min, Order_Pack, PriceEffective, PriceLastInv, PriceLastPO, m_product_po_pricelist, PricePO, m_product_po_qualityrating, RoyaltyAmt, m_product_po_upc, m_product_po_updated, M_Product_PO_UpdatedBy, m_product_po_vendorcategory, S_ResourceAssignment_AD_Org_ID, AssignDateFrom, AssignDateTo, s_resourceassignment_created, s_resourceassignment_createby, s_resourceassignment_isactive, IsConfirmed, s_resourceassignment_name, s_resourceassignment_qty, s_resourceassignment_s_resour, s_resourceassignment_updated, S_ResourceAssignment_UpdatedBy, C_Charge_C_Org_ID, C_Charge_C_BPartner_ID, C_ChargeType_ID, c_charge_chargeamt, C_Charge_C_TaxCategory_ID, c_charge_description, c_charge_isactive, IsSameCurrency, IsSameTax, c_charge_istaxincluded, C_BPartner_Product_AD_Org_ID, C_BP_Product_C_BPartner_ID, c_bpartner_product_created, C_BPartner_Product_CreatedBy, c_bpartner_product_description, c_bpartner_product_isactive, IsManufacturer, c_bpartner_product_manufactur, c_bpartner_product_qualityrat, ShelfLifeMinDays, c_bpartner_product_shelflifem, c_bpartner_product_updated, C_BPartner_Product_UpdatedBy, c_bpartner_product_vendorcate, AcqusitionCost, ActualLifeTimeValue, c_bpartner_ad_language, AD_OrgBP_ID, C_BPartner_AD_Org_ID, BPartner_Parent_ID, C_BP_Group_ID, C_Dunning_ID, C_Greeting_ID, C_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, DUNS, c_bpartner_firstsale, c_bpartner_flatdiscount, c_bpartner_freightcostrule, c_bpartner_invoicerule, c_bpartner_isactive, IsCustomer, c_bpartner_isdiscountprinted, c_bpartner_isemployee, c_bpartner_ismanufacturer, IsOneTime, IsPOTaxExempt, IsProspect, IsSalesRep, c_bpartner_issummary, c_bpartner_istaxexempt, IsVendor, Logo_ID, M_DiscountSchema_ID, C_BPartner_M_PriceList_ID, NAICS, c_bpartner_name, c_bpartner_name2, NumberEmployees, c_bpartner_paymentrule, PaymentRulePO, PO_DiscountSchema_ID, PO_PaymentTerm_ID, PO_PriceList_ID, c_bpartner_poreference, PotentialLifeTimeValue, c_bpartner_rating, c_bpartner_referenceno, C_BPartner_SalesRep_ID, SalesVolume, c_bpartner_sendemail, ShareOfCustomer, c_bpartner_shelflifeminpct, SO_CreditLimit, SOCreditStatus, SO_CreditUsed, SO_Description, c_bpartner_taxid, TotalOpenBalance, c_bpartner_updated, C_BPartner_UpdatedBy, c_bpartner_url, c_bpartner_value, C_BPartner_Location_AD_Org_ID, c_bpartner_location_c_bpartne, 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, C_Tax_AD_Org_ID, AD_Rule_ID, C_Country_ID, C_Region_ID, C_Tax_C_TaxCategory_ID, c_tax_description, c_tax_isactive, c_tax_isdefault, IsDocumentLevel, IsSalesTax, c_tax_issummary, c_tax_istaxexempt, c_tax_name, Parent_Tax_ID, Rate, RequiresTaxCertificate, SOPOType, To_Country_ID, C_Tax_To_Region_ID, ValidFrom) AS SELECT ol.ad_client_id AS AD_Client_ID, ol.ad_org_id AS AD_Org_ID, ol.isactive AS IsActive, ol.created AS Created, ol.createdby AS CreatedBy, ol.updated AS Updated, ol.updatedby AS UpdatedBy, CAST('en_US' AS CHARACTER VARYING(6)) AS AD_Language, ol.c_order_id AS C_Order_ID, ol.c_orderline_id AS C_OrderLine_ID, ol.c_tax_id AS C_Tax_ID, t.taxindicator AS TaxIndicator, ol.c_bpartner_id AS C_BPartner_ID, ol.c_bpartner_location_id AS C_BPartner_Location_ID, bp.name AS BPName, bpl.c_location_id AS C_Location_ID, ol.line AS Line, p.m_product_id AS M_Product_ID, po.vendorproductno AS VendorProductNo, CASE WHEN ol.qtyordered <> 0 OR ol.m_product_id IS NOT NULL THEN ol.qtyordered ELSE NULL END AS QtyOrdered, CASE WHEN ol.qtyentered <> 0 OR ol.m_product_id IS NOT NULL THEN ol.qtyentered ELSE NULL END AS QtyEntered, CASE WHEN ol.qtyentered <> 0 OR ol.m_product_id IS NOT NULL THEN uom.uomsymbol ELSE NULL END AS UOMSymbol, COALESCE(c.name, (p.name || productattribute(ol.m_attributesetinstance_id)), ol.description) AS Name, CASE WHEN COALESCE(c.name, p.name) IS NOT NULL THEN ol.description ELSE NULL END AS Description, p.documentnote AS DocumentNote, p.upc AS UPC, p.sku AS SKU, COALESCE(pp.vendorproductno, p.value) AS ProductValue, ra.description AS ResourceDescription, CASE WHEN i.isdiscountprinted = 'Y' AND ol.pricelist <> 0 THEN ol.pricelist ELSE NULL END AS PriceList, CASE WHEN i.isdiscountprinted = 'Y' AND ol.pricelist <> 0 AND ol.qtyentered <> 0 THEN ol.pricelist * ol.qtyordered / ol.qtyentered ELSE NULL END AS PriceEnteredList, CASE WHEN i.isdiscountprinted = 'Y' AND ol.pricelist > ol.priceactual AND ol.pricelist <> 0 THEN (ol.pricelist - ol.priceactual) / ol.pricelist * 100 ELSE NULL END AS Discount, CASE WHEN ol.priceactual <> 0 OR ol.m_product_id IS NOT NULL THEN ol.priceactual ELSE NULL END AS PriceActual, CASE WHEN ol.priceentered <> 0 OR ol.m_product_id IS NOT NULL THEN ol.priceentered ELSE NULL END AS PriceEntered, CASE WHEN ol.linenetamt <> 0 OR ol.m_product_id IS NOT NULL THEN ol.linenetamt ELSE NULL END AS LineNetAmt, p.description AS ProductDescription, p.imageurl AS ImageURL, ol.c_campaign_id AS C_Campaign_ID, ol.c_project_id AS C_Project_ID, ol.c_activity_id AS C_Activity_ID, ol.c_projectphase_id AS C_ProjectPhase_ID, ol.c_projecttask_id AS C_ProjectTask_ID, ol.ad_orgtrx_id AS C_OrderLine_AD_OrgTrx_ID, ol.c_charge_id AS C_OrderLine_C_Charge_ID, ol.c_currency_id AS C_OrderLine_C_Currency_ID, ol.c_uom_id AS C_UOM_ID, ol.datedelivered AS DateDelivered, ol.dateinvoiced AS DateInvoiced, ol.dateordered AS DateOrdered, ol.datepromised AS c_orderline_datepromised, ol.freightamt AS c_orderline_freightamt, ol.isdescription AS IsDescription, ol.link_orderline_id AS Link_OrderLine_ID, ol.m_promotion_id AS M_Promotion_ID, ol.m_shipper_id AS C_OrderLine_M_Shipper_ID, ol.m_warehouse_id AS C_OrderLine_M_Warehouse_ID, ol.pricecost AS PriceCost, ol.pricelimit AS PriceLimit, ol.processed AS c_orderline_processed, ol.qtydelivered AS QtyDelivered, ol.qtyinvoiced AS QtyInvoiced, ol.qtylostsales AS QtyLostSales, ol.qtyreserved AS QtyReserved, ol.ref_orderline_id AS Ref_OrderLine_ID, ol.rramt AS RRAmt, ol.rrstartdate AS RRStartDate, ol.s_resourceassignment_id AS S_ResourceAssignment_ID, ol.user1_id AS C_OrderLine_User1_ID, ol.user2_id AS C_OrderLine_User2_ID, uom.ad_org_id AS C_UOM_AD_Org_ID, uom.costingprecision AS CostingPrecision, uom.description AS c_uom_description, uom.isactive AS c_uom_isactive, uom.isdefault AS IsDefault, uom.name AS c_uom_name, uom.stdprecision AS StdPrecision, uom.uomtype AS UOMType, uom.x12de355 AS X12DE355, i.ad_org_id AS C_Order_AD_Org_ID, i.ad_orgtrx_id AS C_Order_AD_OrgTrx_ID, i.ad_user_id AS AD_User_ID, i.amountrefunded AS AmountRefunded, i.amounttendered AS AmountTendered, i.bill_bpartner_id AS Bill_BPartner_ID, i.bill_location_id AS Bill_Location_ID, i.bill_user_id AS Bill_User_ID, i.c_activity_id AS C_Order_C_Activity_ID, i.c_bpartner_id AS C_Order_C_BPartner_ID, i.c_campaign_id AS C_Order_C_Campaign_ID, i.c_cashline_id AS C_CashLine_ID, i.c_cashplanline_id AS C_CashPlanLine_ID, i.c_charge_id AS C_Order_C_Charge_ID, i.c_conversiontype_id AS C_ConversionType_ID, i.c_currency_id AS C_Order_C_Currency_ID, i.c_doctype_id AS C_DocType_ID, i.c_doctypetarget_id AS C_DocTypeTarget_ID, i.chargeamt AS ChargeAmt, i.copyfrom AS CopyFrom, i.c_payment_id AS C_Payment_ID, i.c_paymentterm_id AS C_PaymentTerm_ID, i.c_pos_id AS C_POS_ID, i.c_project_id AS C_Order_C_Project_ID, i.created AS c_order_created, i.createdby AS C_Order_CreatedBy, i.dateacct AS DateAcct, i.dateprinted AS DatePrinted, i.datepromised AS c_order_datepromised, i.deliveryrule AS DeliveryRule, i.deliveryviarule AS DeliveryViaRule, i.description AS c_order_description, i.docaction AS DocAction, i.docstatus AS DocStatus, i.documentno AS DocumentNo, i.dropship_bpartner_id AS DropShip_BPartner_ID, i.dropship_location_id AS DropShip_Location_ID, i.dropship_user_id AS DropShip_User_ID, i.freightamt AS c_order_freightamt, i.freightcostrule AS FreightCostRule, i.grandtotal AS GrandTotal, i.invoicerule AS InvoiceRule, i.isactive AS c_order_isactive, i.isapproved AS IsApproved, i.iscreditapproved AS IsCreditApproved, i.isdelivered AS IsDelivered, i.isdiscountprinted AS c_order_isdiscountprinted, i.isdropship AS c_order_isdropship, i.isinvoiced AS IsInvoiced, i.ispayschedulevalid AS IsPayScheduleValid, i.isprinted AS IsPrinted, i.isselected AS IsSelected, i.isselfservice AS c_order_isselfservice, i.issotrx AS IsSOTrx, i.istaxincluded AS IsTaxIncluded, i.istransferred AS IsTransferred, i.link_order_id AS Link_Order_ID, i.m_freightcategory_id AS C_Order_M_FreightCategory_ID, i.m_pricelist_id AS C_Order_M_PriceList_ID, i.m_shipper_id AS C_Order_M_Shipper_ID, i.m_warehouse_id AS C_Order_M_Warehouse_ID, i.ordertype AS OrderType, i.pay_bpartner_id AS Pay_BPartner_ID, i.pay_location_id AS Pay_Location_ID, i.paymentrule AS c_order_paymentrule, i.poreference AS POReference, i.posted AS Posted, i.priorityrule AS PriorityRule, i.processed AS c_order_processed, i.processedon AS ProcessedOn, i.promotioncode AS PromotionCode, i.ref_order_id AS Ref_Order_ID, i.salesrep_id AS SalesRep_ID, i.sendemail AS c_order_sendemail, i.totallines AS TotalLines, i.updated AS c_order_updated, i.updatedby AS C_Order_UpdatedBy, i.user1_id AS C_Order_User1_ID, i.user2_id AS C_Order_User2_ID, i.volume AS c_order_volume, i.weight AS c_order_weight, p.ad_org_id AS M_Product_AD_Org_ID, p.classification AS Classification, p.copyfrom AS m_product_copyfrom, p.created AS m_product_created, p.createdby AS M_Product_CreatedBy, p.c_revenuerecognition_id AS C_RevenueRecognition_ID, p.c_subscriptiontype_id AS C_SubscriptionType_ID, p.c_taxcategory_id AS C_TaxCategory_ID, p.c_uom_id AS M_Product_C_UOM_ID, p.descriptionurl AS DescriptionURL, p.discontinued AS m_product_discontinued, p.discontinuedat AS m_product_discontinuedat, p.group1 AS Group1, p.group2 AS Group2, p.guaranteedays AS GuaranteeDays, p.guaranteedaysmin AS GuaranteeDaysMin, p.help AS Help, p.isactive AS m_product_isactive, p.isbom AS IsBOM, p.isdropship AS m_product_isdropship, p.isexcludeautodelivery AS IsExcludeAutoDelivery, p.isinvoiceprintdetails AS IsInvoicePrintDetails, p.ispicklistprintdetails AS IsPickListPrintDetails, p.ispurchased AS IsPurchased, p.isselfservice AS m_product_isselfservice, p.issold AS IsSold, p.isstocked AS IsStocked, p.issummary AS m_product_issummary, p.isverified AS IsVerified, p.iswebstorefeatured AS IsWebStoreFeatured, p.lowlevel AS LowLevel, p.m_attributeset_id AS M_AttributeSet_ID, p.m_attributesetinstance_id AS M_AttributeSetInstance_ID, p.m_freightcategory_id AS M_Product_M_FreightCategory_ID, p.m_locator_id AS M_Locator_ID, p.m_product_category_id AS M_Product_Product_Category_ID, p.processing AS m_product_processing, p.producttype AS ProductType, p.r_mailtext_id AS R_MailText_ID, p.salesrep_id AS M_Product_SalesRep_ID, p.s_expensetype_id AS S_ExpenseType_ID, p.shelfdepth AS ShelfDepth, p.shelfheight AS ShelfHeight, p.shelfwidth AS ShelfWidth, p.s_resource_id AS S_Resource_ID, p.unitsperpack AS UnitsPerPack, p.unitsperpallet AS UnitsPerPallet, p.updated AS m_product_updated, p.updatedby AS M_Product_UpdatedBy, p.versionno AS VersionNo, p.volume AS m_product_volume, p.weight AS m_product_weight, po.ad_org_id AS M_Product_PO_AD_Org_ID, po.c_bpartner_id AS M_Product_PO_C_BPartner_ID, po.c_currency_id AS M_Product_PO_C_Currency_ID, po.costperorder AS CostPerOrder, po.created AS m_product_po_created, po.createdby AS M_Product_PO_CreatedBy, po.c_uom_id AS M_Product_PO_C_UOM_ID, po.deliverytime_actual AS DeliveryTime_Actual, po.deliverytime_promised AS DeliveryTime_Promised, po.discontinued AS m_product_po_discontinued, po.discontinuedat AS m_product_po_discontinuedat, po.isactive AS m_product_po_isactive, po.iscurrentvendor AS IsCurrentVendor, po.manufacturer AS m_product_po_manufacturer, po.m_product_id AS M_Product_PO_M_Product_ID, po.order_min AS Order_Min, po.order_pack AS Order_Pack, po.priceeffective AS PriceEffective, po.pricelastinv AS PriceLastInv, po.pricelastpo AS PriceLastPO, po.pricelist AS m_product_po_pricelist, po.pricepo AS PricePO, po.qualityrating AS m_product_po_qualityrating, po.royaltyamt AS RoyaltyAmt, po.upc AS m_product_po_upc, po.updated AS m_product_po_updated, po.updatedby AS M_Product_PO_UpdatedBy, po.vendorcategory AS m_product_po_vendorcategory, ra.ad_org_id AS S_ResourceAssignment_AD_Org_ID, ra.assigndatefrom AS AssignDateFrom, ra.assigndateto AS AssignDateTo, ra.created AS s_resourceassignment_created, ra.createdby AS s_resourceassignment_createby, ra.isactive AS s_resourceassignment_isactive, ra.isconfirmed AS IsConfirmed, ra.name AS s_resourceassignment_name, ra.qty AS s_resourceassignment_qty, ra.s_resource_id AS s_resourceassignment_s_resour, ra.updated AS s_resourceassignment_updated, ra.updatedby AS S_ResourceAssignment_UpdatedBy, c.ad_org_id AS C_Charge_C_Org_ID, c.c_bpartner_id AS C_Charge_C_BPartner_ID, c.c_chargetype_id AS C_ChargeType_ID, c.chargeamt AS c_charge_chargeamt, c.c_taxcategory_id AS C_Charge_C_TaxCategory_ID, c.description AS c_charge_description, c.isactive AS c_charge_isactive, c.issamecurrency AS IsSameCurrency, c.issametax AS IsSameTax, c.istaxincluded AS c_charge_istaxincluded, pp.ad_org_id AS C_BPartner_Product_AD_Org_ID, pp.c_bpartner_id AS C_BP_Product_C_BPartner_ID, pp.created AS c_bpartner_product_created, pp.createdby AS C_BPartner_Product_CreatedBy, pp.description AS c_bpartner_product_description, pp.isactive AS c_bpartner_product_isactive, pp.ismanufacturer AS IsManufacturer, pp.manufacturer AS c_bpartner_product_manufactur, pp.qualityrating AS c_bpartner_product_qualityrat, pp.shelflifemindays AS ShelfLifeMinDays, pp.shelflifeminpct AS c_bpartner_product_shelflifem, pp.updated AS c_bpartner_product_updated, pp.updatedby AS C_BPartner_Product_UpdatedBy, pp.vendorcategory AS c_bpartner_product_vendorcate, bp.acqusitioncost AS AcqusitionCost, bp.actuallifetimevalue AS ActualLifeTimeValue, bp.ad_language AS c_bpartner_ad_language, bp.ad_orgbp_id AS AD_OrgBP_ID, bp.ad_org_id AS C_BPartner_AD_Org_ID, bp.bpartner_parent_id AS BPartner_Parent_ID, bp.c_bp_group_id AS C_BP_Group_ID, bp.c_dunning_id AS C_Dunning_ID, bp.c_greeting_id AS C_Greeting_ID, bp.c_invoiceschedule_id AS C_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.duns AS DUNS, 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 IsCustomer, bp.isdiscountprinted AS c_bpartner_isdiscountprinted, bp.isemployee AS c_bpartner_isemployee, bp.ismanufacturer AS c_bpartner_ismanufacturer, bp.isonetime AS IsOneTime, bp.ispotaxexempt AS IsPOTaxExempt, bp.isprospect AS IsProspect, bp.issalesrep AS IsSalesRep, bp.issummary AS c_bpartner_issummary, bp.istaxexempt AS c_bpartner_istaxexempt, bp.isvendor AS IsVendor, bp.logo_id AS Logo_ID, bp.m_discountschema_id AS M_DiscountSchema_ID, bp.m_pricelist_id AS C_BPartner_M_PriceList_ID, bp.naics AS NAICS, bp.name AS c_bpartner_name, bp.name2 AS c_bpartner_name2, bp.numberemployees AS NumberEmployees, bp.paymentrule AS c_bpartner_paymentrule, bp.paymentrulepo AS PaymentRulePO, bp.po_discountschema_id AS PO_DiscountSchema_ID, bp.po_paymentterm_id AS PO_PaymentTerm_ID, bp.po_pricelist_id AS PO_PriceList_ID, bp.poreference AS c_bpartner_poreference, bp.potentiallifetimevalue AS PotentialLifeTimeValue, bp.rating AS c_bpartner_rating, bp.referenceno AS c_bpartner_referenceno, bp.salesrep_id AS C_BPartner_SalesRep_ID, bp.salesvolume AS SalesVolume, bp.sendemail AS c_bpartner_sendemail, bp.shareofcustomer AS ShareOfCustomer, bp.shelflifeminpct AS c_bpartner_shelflifeminpct, bp.so_creditlimit AS SO_CreditLimit, bp.socreditstatus AS SOCreditStatus, bp.so_creditused AS SO_CreditUsed, bp.so_description AS SO_Description, bp.taxid AS c_bpartner_taxid, bp.totalopenbalance AS TotalOpenBalance, bp.updated AS c_bpartner_updated, bp.updatedby AS C_BPartner_UpdatedBy, bp.url AS c_bpartner_url, bp.value AS c_bpartner_value, bpl.ad_org_id AS C_BPartner_Location_AD_Org_ID, bpl.c_bpartner_id AS c_bpartner_location_c_bpartne, 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, t.ad_org_id AS C_Tax_AD_Org_ID, t.ad_rule_id AS AD_Rule_ID, t.c_country_id AS C_Country_ID, t.c_region_id AS C_Region_ID, t.c_taxcategory_id AS C_Tax_C_TaxCategory_ID, t.description AS c_tax_description, t.isactive AS c_tax_isactive, t.isdefault AS c_tax_isdefault, t.isdocumentlevel AS IsDocumentLevel, t.issalestax AS IsSalesTax, t.issummary AS c_tax_issummary, t.istaxexempt AS c_tax_istaxexempt, t.name AS c_tax_name, t.parent_tax_id AS Parent_Tax_ID, t.rate AS Rate, t.requirestaxcertificate AS RequiresTaxCertificate, t.sopotype AS SOPOType, t.to_country_id AS To_Country_ID, t.to_region_id AS C_Tax_To_Region_ID, t.validfrom AS ValidFrom FROM c_orderline ol JOIN c_uom uom ON ol.c_uom_id = uom.c_uom_id JOIN c_order i ON ol.c_order_id = i.c_order_id LEFT JOIN m_product p ON ol.m_product_id = p.m_product_id LEFT JOIN m_product_po po ON p.m_product_id = po.m_product_id AND i.c_bpartner_id = po.c_bpartner_id LEFT JOIN s_resourceassignment ra ON ol.s_resourceassignment_id = ra.s_resourceassignment_id LEFT JOIN c_charge c ON ol.c_charge_id = c.c_charge_id LEFT JOIN c_bpartner_product pp ON ol.m_product_id = pp.m_product_id AND i.c_bpartner_id = pp.c_bpartner_id JOIN c_bpartner bp ON ol.c_bpartner_id = bp.c_bpartner_id JOIN c_bpartner_location bpl ON ol.c_bpartner_location_id = bpl.c_bpartner_location_id LEFT JOIN c_tax t ON ol.c_tax_id = t.c_tax_id UNION SELECT ol.ad_client_id AS AD_Client_ID, ol.ad_org_id AS AD_Org_ID, ol.isactive AS IsActive, ol.created AS Created, ol.createdby AS CreatedBy, ol.updated AS Updated, ol.updatedby AS UpdatedBy, CAST('en_US' AS CHARACTER VARYING(6)) AS AD_Language, ol.c_order_id AS C_Order_ID, ol.c_orderline_id AS C_OrderLine_ID, ol.c_tax_id AS C_Tax_ID, NULL AS TaxIndicator, NULL AS C_BPartner_ID, NULL AS C_BPartner_Location_ID, NULL AS BPName, NULL AS C_Location_ID, ol.line + bl.line / 100 AS Line, p.m_product_id AS M_Product_ID, po.vendorproductno AS VendorProductNo, CASE WHEN bl.isqtypercentage = 'N' THEN ol.qtyordered * bl.qtybom ELSE ol.qtyordered * (bl.qtybatch / 100) END AS QtyOrdered, CASE WHEN bl.isqtypercentage = 'N' THEN ol.qtyentered * bl.qtybom ELSE ol.qtyentered * (bl.qtybatch / 100) END AS QtyEntered, uom.uomsymbol AS UOMSymbol, p.name AS Name, bl.description AS Description, p.documentnote AS DocumentNote, p.upc AS UPC, p.sku AS SKU, p.value AS ProductValue, NULL AS ResourceDescription, NULL AS PriceList, NULL AS PriceEnteredList, NULL AS Discount, NULL AS PriceActual, NULL AS PriceEntered, NULL AS LineNetAmt, p.description AS ProductDescription, p.imageurl AS ImageURL, ol.c_campaign_id AS C_Campaign_ID, ol.c_project_id AS C_Project_ID, ol.c_activity_id AS C_Activity_ID, ol.c_projectphase_id AS C_ProjectPhase_ID, ol.c_projecttask_id AS C_ProjectTask_ID, ol.ad_orgtrx_id AS C_OrderLine_AD_OrgTrx_ID, ol.c_charge_id AS C_OrderLine_C_Charge_ID, ol.c_currency_id AS C_OrderLine_C_Currency_ID, ol.c_uom_id AS C_UOM_ID, ol.datedelivered AS DateDelivered, ol.dateinvoiced AS DateInvoiced, ol.dateordered AS DateOrdered, ol.datepromised AS c_orderline_datepromised, ol.freightamt AS c_orderline_freightamt, ol.isdescription AS IsDescription, ol.link_orderline_id AS Link_OrderLine_ID, ol.m_promotion_id AS M_Promotion_ID, ol.m_shipper_id AS C_OrderLine_M_Shipper_ID, ol.m_warehouse_id AS C_OrderLine_M_Warehouse_ID, ol.pricecost AS PriceCost, ol.pricelimit AS PriceLimit, ol.processed AS c_orderline_processed, ol.qtydelivered AS QtyDelivered, ol.qtyinvoiced AS QtyInvoiced, ol.qtylostsales AS QtyLostSales, ol.qtyreserved AS QtyReserved, ol.ref_orderline_id AS Ref_OrderLine_ID, ol.rramt AS RRAmt, ol.rrstartdate AS RRStartDate, ol.s_resourceassignment_id AS S_ResourceAssignment_ID, ol.user1_id AS C_OrderLine_User1_ID, ol.user2_id AS C_OrderLine_User2_ID, uom.ad_org_id AS C_UOM_AD_Org_ID, uom.costingprecision AS CostingPrecision, uom.description AS c_uom_description, uom.isactive AS c_uom_isactive, uom.isdefault AS IsDefault, uom.name AS c_uom_name, uom.stdprecision AS StdPrecision, uom.uomtype AS UOMType, uom.x12de355 AS X12DE355, i.ad_org_id AS C_Order_AD_Org_ID, i.ad_orgtrx_id AS C_Order_AD_OrgTrx_ID, i.ad_user_id AS AD_User_ID, i.amountrefunded AS AmountRefunded, i.amounttendered AS AmountTendered, i.bill_bpartner_id AS Bill_BPartner_ID, i.bill_location_id AS Bill_Location_ID, i.bill_user_id AS Bill_User_ID, i.c_activity_id AS C_Order_C_Activity_ID, i.c_bpartner_id AS C_Order_C_BPartner_ID, i.c_campaign_id AS C_Order_C_Campaign_ID, i.c_cashline_id AS C_CashLine_ID, i.c_cashplanline_id AS C_CashPlanLine_ID, i.c_charge_id AS C_Order_C_Charge_ID, i.c_conversiontype_id AS C_ConversionType_ID, i.c_currency_id AS C_Order_C_Currency_ID, i.c_doctype_id AS C_DocType_ID, i.c_doctypetarget_id AS C_DocTypeTarget_ID, i.chargeamt AS ChargeAmt, i.copyfrom AS CopyFrom, i.c_payment_id AS C_Payment_ID, i.c_paymentterm_id AS C_PaymentTerm_ID, i.c_pos_id AS C_POS_ID, i.c_project_id AS C_Order_C_Project_ID, i.created AS c_order_created, i.createdby AS C_Order_CreatedBy, i.dateacct AS DateAcct, i.dateprinted AS DatePrinted, i.datepromised AS c_order_datepromised, i.deliveryrule AS DeliveryRule, i.deliveryviarule AS DeliveryViaRule, i.description AS c_order_description, i.docaction AS DocAction, i.docstatus AS DocStatus, i.documentno AS DocumentNo, i.dropship_bpartner_id AS DropShip_BPartner_ID, i.dropship_location_id AS DropShip_Location_ID, i.dropship_user_id AS DropShip_User_ID, i.freightamt AS c_order_freightamt, i.freightcostrule AS FreightCostRule, i.grandtotal AS GrandTotal, i.invoicerule AS InvoiceRule, i.isactive AS c_order_isactive, i.isapproved AS IsApproved, i.iscreditapproved AS IsCreditApproved, i.isdelivered AS IsDelivered, i.isdiscountprinted AS c_order_isdiscountprinted, i.isdropship AS c_order_isdropship, i.isinvoiced AS IsInvoiced, i.ispayschedulevalid AS IsPayScheduleValid, i.isprinted AS IsPrinted, i.isselected AS IsSelected, i.isselfservice AS c_order_isselfservice, i.issotrx AS IsSOTrx, i.istaxincluded AS IsTaxIncluded, i.istransferred AS IsTransferred, i.link_order_id AS Link_Order_ID, i.m_freightcategory_id AS C_Order_M_FreightCategory_ID, i.m_pricelist_id AS C_Order_M_PriceList_ID, i.m_shipper_id AS C_Order_M_Shipper_ID, i.m_warehouse_id AS C_Order_M_Warehouse_ID, i.ordertype AS OrderType, i.pay_bpartner_id AS Pay_BPartner_ID, i.pay_location_id AS Pay_Location_ID, i.paymentrule AS c_order_paymentrule, i.poreference AS POReference, i.posted AS Posted, i.priorityrule AS PriorityRule, i.processed AS c_order_processed, i.processedon AS ProcessedOn, i.promotioncode AS PromotionCode, i.ref_order_id AS Ref_Order_ID, i.salesrep_id AS SalesRep_ID, i.sendemail AS c_order_sendemail, i.totallines AS TotalLines, i.updated AS c_order_updated, i.updatedby AS C_Order_UpdatedBy, i.user1_id AS C_Order_User1_ID, i.user2_id AS C_Order_User2_ID, i.volume AS c_order_volume, i.weight AS c_order_weight, p.ad_org_id AS M_Product_AD_Org_ID, p.classification AS Classification, p.copyfrom AS m_product_copyfrom, p.created AS m_product_created, p.createdby AS M_Product_CreatedBy, p.c_revenuerecognition_id AS C_RevenueRecognition_ID, p.c_subscriptiontype_id AS C_SubscriptionType_ID, p.c_taxcategory_id AS C_TaxCategory_ID, p.c_uom_id AS M_Product_C_UOM_ID, p.descriptionurl AS DescriptionURL, p.discontinued AS m_product_discontinued, p.discontinuedat AS m_product_discontinuedat, p.group1 AS Group1, p.group2 AS Group2, p.guaranteedays AS GuaranteeDays, p.guaranteedaysmin AS GuaranteeDaysMin, p.help AS Help, p.isactive AS m_product_isactive, p.isbom AS IsBOM, p.isdropship AS m_product_isdropship, p.isexcludeautodelivery AS IsExcludeAutoDelivery, p.isinvoiceprintdetails AS IsInvoicePrintDetails, p.ispicklistprintdetails AS IsPickListPrintDetails, p.ispurchased AS IsPurchased, p.isselfservice AS m_product_isselfservice, p.issold AS IsSold, p.isstocked AS IsStocked, p.issummary AS m_product_issummary, p.isverified AS IsVerified, p.iswebstorefeatured AS IsWebStoreFeatured, p.lowlevel AS LowLevel, p.m_attributeset_id AS M_AttributeSet_ID, p.m_attributesetinstance_id AS M_AttributeSetInstance_ID, p.m_freightcategory_id AS M_Product_M_FreightCategory_ID, p.m_locator_id AS M_Locator_ID, p.m_product_category_id AS M_Product_Product_Category_ID, p.processing AS m_product_processing, p.producttype AS ProductType, p.r_mailtext_id AS R_MailText_ID, p.salesrep_id AS M_Product_SalesRep_ID, p.s_expensetype_id AS S_ExpenseType_ID, p.shelfdepth AS ShelfDepth, p.shelfheight AS ShelfHeight, p.shelfwidth AS ShelfWidth, p.s_resource_id AS S_Resource_ID, p.unitsperpack AS UnitsPerPack, p.unitsperpallet AS UnitsPerPallet, p.updated AS m_product_updated, p.updatedby AS M_Product_UpdatedBy, p.versionno AS VersionNo, p.volume AS m_product_volume, p.weight AS m_product_weight, po.ad_org_id AS M_Product_PO_AD_Org_ID, po.c_bpartner_id AS M_Product_PO_C_BPartner_ID, po.c_currency_id AS M_Product_PO_C_Currency_ID, po.costperorder AS CostPerOrder, po.created AS m_product_po_created, po.createdby AS M_Product_PO_CreatedBy, po.c_uom_id AS M_Product_PO_C_UOM_ID, po.deliverytime_actual AS DeliveryTime_Actual, po.deliverytime_promised AS DeliveryTime_Promised, po.discontinued AS m_product_po_discontinued, po.discontinuedat AS m_product_po_discontinuedat, po.isactive AS m_product_po_isactive, po.iscurrentvendor AS IsCurrentVendor, po.manufacturer AS m_product_po_manufacturer, po.m_product_id AS M_Product_PO_M_Product_ID, po.order_min AS Order_Min, po.order_pack AS Order_Pack, po.priceeffective AS PriceEffective, po.pricelastinv AS PriceLastInv, po.pricelastpo AS PriceLastPO, po.pricelist AS m_product_po_pricelist, po.pricepo AS PricePO, po.qualityrating AS m_product_po_qualityrating, po.royaltyamt AS RoyaltyAmt, po.upc AS m_product_po_upc, po.updated AS m_product_po_updated, po.updatedby AS M_Product_PO_UpdatedBy, po.vendorcategory AS m_product_po_vendorcategory, NULL AS S_ResourceAssignment_AD_Org_ID, NULL AS AssignDateFrom, NULL AS AssignDateTo, NULL AS s_resourceassignment_created, NULL AS s_resourceassignment_createby, NULL AS s_resourceassignment_isactive, NULL AS IsConfirmed, NULL AS s_resourceassignment_name, NULL AS s_resourceassignment_qty, NULL AS s_resourceassignment_s_resour, NULL AS s_resourceassignment_updated, NULL AS S_ResourceAssignment_UpdatedBy, NULL AS C_Charge_C_Org_ID, NULL AS C_Charge_C_BPartner_ID, NULL AS C_ChargeType_ID, NULL AS c_charge_chargeamt, NULL AS C_Charge_C_TaxCategory_ID, NULL AS c_charge_description, NULL AS c_charge_isactive, NULL AS IsSameCurrency, NULL AS IsSameTax, NULL AS c_charge_istaxincluded, NULL AS C_BPartner_Product_AD_Org_ID, NULL AS C_BP_Product_C_BPartner_ID, NULL AS c_bpartner_product_created, NULL AS C_BPartner_Product_CreatedBy, NULL AS c_bpartner_product_description, NULL AS c_bpartner_product_isactive, NULL AS IsManufacturer, NULL AS c_bpartner_product_manufactur, NULL AS c_bpartner_product_qualityrat, NULL AS ShelfLifeMinDays, NULL AS c_bpartner_product_shelflifem, NULL AS c_bpartner_product_updated, NULL AS C_BPartner_Product_UpdatedBy, NULL AS c_bpartner_product_vendorcate, NULL AS AcqusitionCost, NULL AS ActualLifeTimeValue, NULL AS c_bpartner_ad_language, NULL AS AD_OrgBP_ID, NULL AS C_BPartner_AD_Org_ID, NULL AS BPartner_Parent_ID, NULL AS C_BP_Group_ID, NULL AS C_Dunning_ID, NULL AS C_Greeting_ID, NULL AS C_InvoiceSchedule_ID, NULL AS C_BPartner_C_PaymentTerm_ID, NULL AS c_bpartner_created, NULL AS C_BPartner_CreatedBy, NULL AS C_BPartner_C_TaxGroup_ID, NULL AS c_bpartner_deliveryrule, NULL AS c_bpartner_deliveryviarule, NULL AS c_bpartner_description, NULL AS c_bpartner_dunninggrace, NULL AS DUNS, NULL AS c_bpartner_firstsale, NULL AS c_bpartner_flatdiscount, NULL AS c_bpartner_freightcostrule, NULL AS c_bpartner_invoicerule, NULL AS c_bpartner_isactive, NULL AS IsCustomer, NULL AS c_bpartner_isdiscountprinted, NULL AS c_bpartner_isemployee, NULL AS c_bpartner_ismanufacturer, NULL AS IsOneTime, NULL AS IsPOTaxExempt, NULL AS IsProspect, NULL AS IsSalesRep, NULL AS c_bpartner_issummary, NULL AS c_bpartner_istaxexempt, NULL AS IsVendor, NULL AS Logo_ID, NULL AS M_DiscountSchema_ID, NULL AS C_BPartner_M_PriceList_ID, NULL AS NAICS, NULL AS c_bpartner_name, NULL AS c_bpartner_name2, NULL AS NumberEmployees, NULL AS c_bpartner_paymentrule, NULL AS PaymentRulePO, NULL AS PO_DiscountSchema_ID, NULL AS PO_PaymentTerm_ID, NULL AS PO_PriceList_ID, NULL AS c_bpartner_poreference, NULL AS PotentialLifeTimeValue, NULL AS c_bpartner_rating, NULL AS c_bpartner_referenceno, NULL AS C_BPartner_SalesRep_ID, NULL AS SalesVolume, NULL AS c_bpartner_sendemail, NULL AS ShareOfCustomer, NULL AS c_bpartner_shelflifeminpct, NULL AS SO_CreditLimit, NULL AS SOCreditStatus, NULL AS SO_CreditUsed, NULL AS SO_Description, NULL AS c_bpartner_taxid, NULL AS TotalOpenBalance, NULL AS c_bpartner_updated, NULL AS C_BPartner_UpdatedBy, NULL AS c_bpartner_url, NULL AS c_bpartner_value, NULL AS C_BPartner_Location_AD_Org_ID, NULL AS c_bpartner_location_c_bpartne, NULL AS c_bpartner_location_created, NULL AS C_BPartner_Location_CreatedBy, NULL AS C_SalesRegion_ID, NULL AS c_bpartner_location_fax, NULL AS c_bpartner_location_isactive, NULL AS IsBillTo, NULL AS ISDN, NULL AS IsPayFrom, NULL AS IsRemitTo, NULL AS IsShipTo, NULL AS c_bpartner_location_name, NULL AS c_bpartner_location_phone, NULL AS c_bpartner_location_phone2, NULL AS c_bpartner_location_updated, NULL AS C_BPartner_Location_UpdatedBy, NULL AS C_Tax_AD_Org_ID, NULL AS AD_Rule_ID, NULL AS C_Country_ID, NULL AS C_Region_ID, NULL AS C_Tax_C_TaxCategory_ID, NULL AS c_tax_description, NULL AS c_tax_isactive, NULL AS c_tax_isdefault, NULL AS IsDocumentLevel, NULL AS IsSalesTax, NULL AS c_tax_issummary, NULL AS c_tax_istaxexempt, NULL AS c_tax_name, NULL AS Parent_Tax_ID, NULL AS Rate, NULL AS RequiresTaxCertificate, NULL AS SOPOType, NULL AS To_Country_ID, NULL AS C_Tax_To_Region_ID, NULL AS ValidFrom FROM pp_product_bom b JOIN c_orderline ol ON b.m_product_id = ol.m_product_id JOIN c_order i ON ol.c_order_id = i.c_order_id JOIN m_product bp ON bp.m_product_id = ol.m_product_id AND bp.isbom = 'Y' AND bp.isverified = 'Y' AND bp.isinvoiceprintdetails = 'Y' JOIN pp_product_bomline bl ON bl.pp_product_bom_id = b.pp_product_bom_id JOIN m_product p ON p.m_product_id = bl.m_product_id LEFT JOIN m_product_po po ON p.m_product_id = po.m_product_id AND i.c_bpartner_id = po.c_bpartner_id JOIN c_uom uom ON p.c_uom_id = uom.c_uom_id UNION 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_order_id AS C_Order_ID, NULL AS C_OrderLine_ID, NULL AS C_Tax_ID, NULL AS TaxIndicator, NULL AS C_BPartner_ID, NULL AS C_BPartner_Location_ID, NULL AS BPName, NULL AS C_Location_ID, 999998 AS Line, NULL AS M_Product_ID, NULL AS VendorProductNo, NULL AS QtyOrdered, NULL AS QtyEntered, NULL AS UOMSymbol, NULL AS Name, NULL AS Description, NULL AS DocumentNote, NULL AS UPC, NULL AS SKU, NULL AS ProductValue, NULL AS ResourceDescription, NULL AS PriceList, NULL AS PriceEnteredList, NULL AS Discount, NULL AS PriceActual, NULL AS PriceEntered, NULL AS LineNetAmt, NULL AS ProductDescription, NULL AS ImageURL, NULL AS C_Campaign_ID, NULL AS C_Project_ID, NULL AS C_Activity_ID, NULL AS C_ProjectPhase_ID, NULL AS C_ProjectTask_ID, NULL AS C_OrderLine_AD_OrgTrx_ID, NULL AS C_OrderLine_C_Charge_ID, NULL AS C_OrderLine_C_Currency_ID, NULL AS C_UOM_ID, NULL AS DateDelivered, NULL AS DateInvoiced, NULL AS DateOrdered, NULL AS c_orderline_datepromised, NULL AS c_orderline_freightamt, NULL AS IsDescription, NULL AS Link_OrderLine_ID, NULL AS M_Promotion_ID, NULL AS C_OrderLine_M_Shipper_ID, NULL AS C_OrderLine_M_Warehouse_ID, NULL AS PriceCost, NULL AS PriceLimit, NULL AS c_orderline_processed, NULL AS QtyDelivered, NULL AS QtyInvoiced, NULL AS QtyLostSales, NULL AS QtyReserved, NULL AS Ref_OrderLine_ID, NULL AS RRAmt, NULL AS RRStartDate, NULL AS S_ResourceAssignment_ID, NULL AS C_OrderLine_User1_ID, NULL AS C_OrderLine_User2_ID, NULL AS C_UOM_AD_Org_ID, NULL AS CostingPrecision, NULL AS c_uom_description, NULL AS c_uom_isactive, NULL AS IsDefault, NULL AS c_uom_name, NULL AS StdPrecision, NULL AS UOMType, NULL AS X12DE355, NULL AS C_Order_AD_Org_ID, NULL AS C_Order_AD_OrgTrx_ID, NULL AS AD_User_ID, NULL AS AmountRefunded, NULL AS AmountTendered, NULL AS Bill_BPartner_ID, NULL AS Bill_Location_ID, NULL AS Bill_User_ID, NULL AS C_Order_C_Activity_ID, NULL AS C_Order_C_BPartner_ID, NULL AS C_Order_C_Campaign_ID, NULL AS C_CashLine_ID, NULL AS C_CashPlanLine_ID, NULL AS C_Order_C_Charge_ID, NULL AS C_ConversionType_ID, NULL AS C_Order_C_Currency_ID, NULL AS C_DocType_ID, NULL AS C_DocTypeTarget_ID, NULL AS ChargeAmt, NULL AS CopyFrom, NULL AS C_Payment_ID, NULL AS C_PaymentTerm_ID, NULL AS C_POS_ID, NULL AS C_Order_C_Project_ID, NULL AS c_order_created, NULL AS C_Order_CreatedBy, NULL AS DateAcct, NULL AS DatePrinted, NULL AS c_order_datepromised, NULL AS DeliveryRule, NULL AS DeliveryViaRule, NULL AS c_order_description, NULL AS DocAction, NULL AS DocStatus, NULL AS DocumentNo, NULL AS DropShip_BPartner_ID, NULL AS DropShip_Location_ID, NULL AS DropShip_User_ID, NULL AS c_order_freightamt, NULL AS FreightCostRule, NULL AS GrandTotal, NULL AS InvoiceRule, NULL AS c_order_isactive, NULL AS IsApproved, NULL AS IsCreditApproved, NULL AS IsDelivered, NULL AS c_order_isdiscountprinted, NULL AS c_order_isdropship, NULL AS IsInvoiced, NULL AS IsPayScheduleValid, NULL AS IsPrinted, NULL AS IsSelected, NULL AS c_order_isselfservice, NULL AS IsSOTrx, NULL AS IsTaxIncluded, NULL AS IsTransferred, NULL AS Link_Order_ID, NULL AS C_Order_M_FreightCategory_ID, NULL AS C_Order_M_PriceList_ID, NULL AS C_Order_M_Shipper_ID, NULL AS C_Order_M_Warehouse_ID, NULL AS OrderType, NULL AS Pay_BPartner_ID, NULL AS Pay_Location_ID, NULL AS c_order_paymentrule, NULL AS POReference, NULL AS Posted, NULL AS PriorityRule, NULL AS c_order_processed, NULL AS ProcessedOn, NULL AS PromotionCode, NULL AS Ref_Order_ID, NULL AS SalesRep_ID, NULL AS c_order_sendemail, NULL AS TotalLines, NULL AS c_order_updated, NULL AS C_Order_UpdatedBy, NULL AS C_Order_User1_ID, NULL AS C_Order_User2_ID, NULL AS c_order_volume, NULL AS c_order_weight, NULL AS M_Product_AD_Org_ID, NULL AS Classification, NULL AS m_product_copyfrom, NULL AS m_product_created, NULL AS M_Product_CreatedBy, NULL AS C_RevenueRecognition_ID, NULL AS C_SubscriptionType_ID, NULL AS C_TaxCategory_ID, NULL AS M_Product_C_UOM_ID, NULL AS DescriptionURL, NULL AS m_product_discontinued, NULL AS m_product_discontinuedat, NULL AS Group1, NULL AS Group2, NULL AS GuaranteeDays, NULL AS GuaranteeDaysMin, NULL AS Help, NULL AS m_product_isactive, NULL AS IsBOM, NULL AS m_product_isdropship, NULL AS IsExcludeAutoDelivery, NULL AS IsInvoicePrintDetails, NULL AS IsPickListPrintDetails, NULL AS IsPurchased, NULL AS m_product_isselfservice, NULL AS IsSold, NULL AS IsStocked, NULL AS m_product_issummary, NULL AS IsVerified, NULL AS IsWebStoreFeatured, NULL AS LowLevel, NULL AS M_AttributeSet_ID, NULL AS M_AttributeSetInstance_ID, NULL AS M_Product_M_FreightCategory_ID, NULL AS M_Locator_ID, NULL AS M_Product_Product_Category_ID, NULL AS m_product_processing, NULL AS ProductType, NULL AS R_MailText_ID, NULL AS M_Product_SalesRep_ID, NULL AS S_ExpenseType_ID, NULL AS ShelfDepth, NULL AS ShelfHeight, NULL AS ShelfWidth, NULL AS S_Resource_ID, NULL AS UnitsPerPack, NULL AS UnitsPerPallet, NULL AS m_product_updated, NULL AS M_Product_UpdatedBy, NULL AS VersionNo, NULL AS m_product_volume, NULL AS m_product_weight, NULL AS M_Product_PO_AD_Org_ID, NULL AS M_Product_PO_C_BPartner_ID, NULL AS M_Product_PO_C_Currency_ID, NULL AS CostPerOrder, NULL AS m_product_po_created, NULL AS M_Product_PO_CreatedBy, NULL AS M_Product_PO_C_UOM_ID, NULL AS DeliveryTime_Actual, NULL AS DeliveryTime_Promised, NULL AS m_product_po_discontinued, NULL AS m_product_po_discontinuedat, NULL AS m_product_po_isactive, NULL AS IsCurrentVendor, NULL AS m_product_po_manufacturer, NULL AS M_Product_PO_M_Product_ID, NULL AS Order_Min, NULL AS Order_Pack, NULL AS PriceEffective, NULL AS PriceLastInv, NULL AS PriceLastPO, NULL AS m_product_po_pricelist, NULL AS PricePO, NULL AS m_product_po_qualityrating, NULL AS RoyaltyAmt, NULL AS m_product_po_upc, NULL AS m_product_po_updated, NULL AS M_Product_PO_UpdatedBy, NULL AS m_product_po_vendorcategory, NULL AS S_ResourceAssignment_AD_Org_ID, NULL AS AssignDateFrom, NULL AS AssignDateTo, NULL AS s_resourceassignment_created, NULL AS s_resourceassignment_createby, NULL AS s_resourceassignment_isactive, NULL AS IsConfirmed, NULL AS s_resourceassignment_name, NULL AS s_resourceassignment_qty, NULL AS s_resourceassignment_s_resour, NULL AS s_resourceassignment_updated, NULL AS S_ResourceAssignment_UpdatedBy, NULL AS C_Charge_C_Org_ID, NULL AS C_Charge_C_BPartner_ID, NULL AS C_ChargeType_ID, NULL AS c_charge_chargeamt, NULL AS C_Charge_C_TaxCategory_ID, NULL AS c_charge_description, NULL AS c_charge_isactive, NULL AS IsSameCurrency, NULL AS IsSameTax, NULL AS c_charge_istaxincluded, NULL AS C_BPartner_Product_AD_Org_ID, NULL AS C_BP_Product_C_BPartner_ID, NULL AS c_bpartner_product_created, NULL AS C_BPartner_Product_CreatedBy, NULL AS c_bpartner_product_description, NULL AS c_bpartner_product_isactive, NULL AS IsManufacturer, NULL AS c_bpartner_product_manufactur, NULL AS c_bpartner_product_qualityrat, NULL AS ShelfLifeMinDays, NULL AS c_bpartner_product_shelflifem, NULL AS c_bpartner_product_updated, NULL AS C_BPartner_Product_UpdatedBy, NULL AS c_bpartner_product_vendorcate, NULL AS AcqusitionCost, NULL AS ActualLifeTimeValue, NULL AS c_bpartner_ad_language, NULL AS AD_OrgBP_ID, NULL AS C_BPartner_AD_Org_ID, NULL AS BPartner_Parent_ID, NULL AS C_BP_Group_ID, NULL AS C_Dunning_ID, NULL AS C_Greeting_ID, NULL AS C_InvoiceSchedule_ID, NULL AS C_BPartner_C_PaymentTerm_ID, NULL AS c_bpartner_created, NULL AS C_BPartner_CreatedBy, NULL AS C_BPartner_C_TaxGroup_ID, NULL AS c_bpartner_deliveryrule, NULL AS c_bpartner_deliveryviarule, NULL AS c_bpartner_description, NULL AS c_bpartner_dunninggrace, NULL AS DUNS, NULL AS c_bpartner_firstsale, NULL AS c_bpartner_flatdiscount, NULL AS c_bpartner_freightcostrule, NULL AS c_bpartner_invoicerule, NULL AS c_bpartner_isactive, NULL AS IsCustomer, NULL AS c_bpartner_isdiscountprinted, NULL AS c_bpartner_isemployee, NULL AS c_bpartner_ismanufacturer, NULL AS IsOneTime, NULL AS IsPOTaxExempt, NULL AS IsProspect, NULL AS IsSalesRep, NULL AS c_bpartner_issummary, NULL AS c_bpartner_istaxexempt, NULL AS IsVendor, NULL AS Logo_ID, NULL AS M_DiscountSchema_ID, NULL AS C_BPartner_M_PriceList_ID, NULL AS NAICS, NULL AS c_bpartner_name, NULL AS c_bpartner_name2, NULL AS NumberEmployees, NULL AS c_bpartner_paymentrule, NULL AS PaymentRulePO, NULL AS PO_DiscountSchema_ID, NULL AS PO_PaymentTerm_ID, NULL AS PO_PriceList_ID, NULL AS c_bpartner_poreference, NULL AS PotentialLifeTimeValue, NULL AS c_bpartner_rating, NULL AS c_bpartner_referenceno, NULL AS C_BPartner_SalesRep_ID, NULL AS SalesVolume, NULL AS c_bpartner_sendemail, NULL AS ShareOfCustomer, NULL AS c_bpartner_shelflifeminpct, NULL AS SO_CreditLimit, NULL AS SOCreditStatus, NULL AS SO_CreditUsed, NULL AS SO_Description, NULL AS c_bpartner_taxid, NULL AS TotalOpenBalance, NULL AS c_bpartner_updated, NULL AS C_BPartner_UpdatedBy, NULL AS c_bpartner_url, NULL AS c_bpartner_value, NULL AS C_BPartner_Location_AD_Org_ID, NULL AS c_bpartner_location_c_bpartne, NULL AS c_bpartner_location_created, NULL AS C_BPartner_Location_CreatedBy, NULL AS C_SalesRegion_ID, NULL AS c_bpartner_location_fax, NULL AS c_bpartner_location_isactive, NULL AS IsBillTo, NULL AS ISDN, NULL AS IsPayFrom, NULL AS IsRemitTo, NULL AS IsShipTo, NULL AS c_bpartner_location_name, NULL AS c_bpartner_location_phone, NULL AS c_bpartner_location_phone2, NULL AS c_bpartner_location_updated, NULL AS C_BPartner_Location_UpdatedBy, NULL AS C_Tax_AD_Org_ID, NULL AS AD_Rule_ID, NULL AS C_Country_ID, NULL AS C_Region_ID, NULL AS C_Tax_C_TaxCategory_ID, NULL AS c_tax_description, NULL AS c_tax_isactive, NULL AS c_tax_isdefault, NULL AS IsDocumentLevel, NULL AS IsSalesTax, NULL AS c_tax_issummary, NULL AS c_tax_istaxexempt, NULL AS c_tax_name, NULL AS Parent_Tax_ID, NULL AS Rate, NULL AS RequiresTaxCertificate, NULL AS SOPOType, NULL AS To_Country_ID, NULL AS C_Tax_To_Region_ID, NULL AS ValidFrom FROM c_order i UNION SELECT ot.ad_client_id AS AD_Client_ID, ot.ad_org_id AS AD_Org_ID, ot.isactive AS IsActive, ot.created AS Created, ot.createdby AS CreatedBy, ot.updated AS Updated, ot.updatedby AS UpdatedBy, CAST('en_US' AS CHARACTER VARYING(6)) AS AD_Language, ot.c_order_id AS C_Order_ID, NULL AS C_OrderLine_ID, ot.c_tax_id AS C_Tax_ID, t.taxindicator AS TaxIndicator, NULL AS C_BPartner_ID, NULL AS C_BPartner_Location_ID, NULL AS BPName, NULL AS C_Location_ID, 999999 AS Line, NULL AS M_Product_ID, NULL AS VendorProductNo, NULL AS QtyOrdered, NULL AS QtyEntered, NULL AS UOMSymbol, t.name AS Name, NULL AS Description, NULL AS DocumentNote, NULL AS UPC, NULL AS SKU, NULL AS ProductValue, NULL AS ResourceDescription, NULL AS PriceList, NULL AS PriceEnteredList, NULL AS Discount, CASE WHEN ot.istaxincluded = 'Y' THEN ot.taxamt ELSE ot.taxbaseamt END AS PriceActual, CASE WHEN ot.istaxincluded = 'Y' THEN ot.taxamt ELSE ot.taxbaseamt END AS PriceEntered, CASE WHEN ot.istaxincluded = 'Y' THEN NULL ELSE ot.taxamt END AS LineNetAmt, NULL AS ProductDescription, NULL AS ImageURL, NULL AS C_Campaign_ID, NULL AS C_Project_ID, NULL AS C_Activity_ID, NULL AS C_ProjectPhase_ID, NULL AS C_ProjectTask_ID, NULL AS C_OrderLine_AD_OrgTrx_ID, NULL AS C_OrderLine_C_Charge_ID, NULL AS C_OrderLine_C_Currency_ID, NULL AS C_UOM_ID, NULL AS DateDelivered, NULL AS DateInvoiced, NULL AS DateOrdered, NULL AS c_orderline_datepromised, NULL AS c_orderline_freightamt, NULL AS IsDescription, NULL AS Link_OrderLine_ID, NULL AS M_Promotion_ID, NULL AS C_OrderLine_M_Shipper_ID, NULL AS C_OrderLine_M_Warehouse_ID, NULL AS PriceCost, NULL AS PriceLimit, NULL AS c_orderline_processed, NULL AS QtyDelivered, NULL AS QtyInvoiced, NULL AS QtyLostSales, NULL AS QtyReserved, NULL AS Ref_OrderLine_ID, NULL AS RRAmt, NULL AS RRStartDate, NULL AS S_ResourceAssignment_ID, NULL AS C_OrderLine_User1_ID, NULL AS C_OrderLine_User2_ID, NULL AS C_UOM_AD_Org_ID, NULL AS CostingPrecision, NULL AS c_uom_description, NULL AS c_uom_isactive, NULL AS IsDefault, NULL AS c_uom_name, NULL AS StdPrecision, NULL AS UOMType, NULL AS X12DE355, NULL AS C_Order_AD_Org_ID, NULL AS C_Order_AD_OrgTrx_ID, NULL AS AD_User_ID, NULL AS AmountRefunded, NULL AS AmountTendered, NULL AS Bill_BPartner_ID, NULL AS Bill_Location_ID, NULL AS Bill_User_ID, NULL AS C_Order_C_Activity_ID, NULL AS C_Order_C_BPartner_ID, NULL AS C_Order_C_Campaign_ID, NULL AS C_CashLine_ID, NULL AS C_CashPlanLine_ID, NULL AS C_Order_C_Charge_ID, NULL AS C_ConversionType_ID, NULL AS C_Order_C_Currency_ID, NULL AS C_DocType_ID, NULL AS C_DocTypeTarget_ID, NULL AS ChargeAmt, NULL AS CopyFrom, NULL AS C_Payment_ID, NULL AS C_PaymentTerm_ID, NULL AS C_POS_ID, NULL AS C_Order_C_Project_ID, NULL AS c_order_created, NULL AS C_Order_CreatedBy, NULL AS DateAcct, NULL AS DatePrinted, NULL AS c_order_datepromised, NULL AS DeliveryRule, NULL AS DeliveryViaRule, NULL AS c_order_description, NULL AS DocAction, NULL AS DocStatus, NULL AS DocumentNo, NULL AS DropShip_BPartner_ID, NULL AS DropShip_Location_ID, NULL AS DropShip_User_ID, NULL AS c_order_freightamt, NULL AS FreightCostRule, NULL AS GrandTotal, NULL AS InvoiceRule, NULL AS c_order_isactive, NULL AS IsApproved, NULL AS IsCreditApproved, NULL AS IsDelivered, NULL AS c_order_isdiscountprinted, NULL AS c_order_isdropship, NULL AS IsInvoiced, NULL AS IsPayScheduleValid, NULL AS IsPrinted, NULL AS IsSelected, NULL AS c_order_isselfservice, NULL AS IsSOTrx, NULL AS IsTaxIncluded, NULL AS IsTransferred, NULL AS Link_Order_ID, NULL AS C_Order_M_FreightCategory_ID, NULL AS C_Order_M_PriceList_ID, NULL AS C_Order_M_Shipper_ID, NULL AS C_Order_M_Warehouse_ID, NULL AS OrderType, NULL AS Pay_BPartner_ID, NULL AS Pay_Location_ID, NULL AS c_order_paymentrule, NULL AS POReference, NULL AS Posted, NULL AS PriorityRule, NULL AS c_order_processed, NULL AS ProcessedOn, NULL AS PromotionCode, NULL AS Ref_Order_ID, NULL AS SalesRep_ID, NULL AS c_order_sendemail, NULL AS TotalLines, NULL AS c_order_updated, NULL AS C_Order_UpdatedBy, NULL AS C_Order_User1_ID, NULL AS C_Order_User2_ID, NULL AS c_order_volume, NULL AS c_order_weight, NULL AS M_Product_AD_Org_ID, NULL AS Classification, NULL AS m_product_copyfrom, NULL AS m_product_created, NULL AS M_Product_CreatedBy, NULL AS C_RevenueRecognition_ID, NULL AS C_SubscriptionType_ID, NULL AS C_TaxCategory_ID, NULL AS M_Product_C_UOM_ID, NULL AS DescriptionURL, NULL AS m_product_discontinued, NULL AS m_product_discontinuedat, NULL AS Group1, NULL AS Group2, NULL AS GuaranteeDays, NULL AS GuaranteeDaysMin, NULL AS Help, NULL AS m_product_isactive, NULL AS IsBOM, NULL AS m_product_isdropship, NULL AS IsExcludeAutoDelivery, NULL AS IsInvoicePrintDetails, NULL AS IsPickListPrintDetails, NULL AS IsPurchased, NULL AS m_product_isselfservice, NULL AS IsSold, NULL AS IsStocked, NULL AS m_product_issummary, NULL AS IsVerified, NULL AS IsWebStoreFeatured, NULL AS LowLevel, NULL AS M_AttributeSet_ID, NULL AS M_AttributeSetInstance_ID, NULL AS M_Product_M_FreightCategory_ID, NULL AS M_Locator_ID, NULL AS M_Product_Product_Category_ID, NULL AS m_product_processing, NULL AS ProductType, NULL AS R_MailText_ID, NULL AS M_Product_SalesRep_ID, NULL AS S_ExpenseType_ID, NULL AS ShelfDepth, NULL AS ShelfHeight, NULL AS ShelfWidth, NULL AS S_Resource_ID, NULL AS UnitsPerPack, NULL AS UnitsPerPallet, NULL AS m_product_updated, NULL AS M_Product_UpdatedBy, NULL AS VersionNo, NULL AS m_product_volume, NULL AS m_product_weight, NULL AS M_Product_PO_AD_Org_ID, NULL AS M_Product_PO_C_BPartner_ID, NULL AS M_Product_PO_C_Currency_ID, NULL AS CostPerOrder, NULL AS m_product_po_created, NULL AS M_Product_PO_CreatedBy, NULL AS M_Product_PO_C_UOM_ID, NULL AS DeliveryTime_Actual, NULL AS DeliveryTime_Promised, NULL AS m_product_po_discontinued, NULL AS m_product_po_discontinuedat, NULL AS m_product_po_isactive, NULL AS IsCurrentVendor, NULL AS m_product_po_manufacturer, NULL AS M_Product_PO_M_Product_ID, NULL AS Order_Min, NULL AS Order_Pack, NULL AS PriceEffective, NULL AS PriceLastInv, NULL AS PriceLastPO, NULL AS m_product_po_pricelist, NULL AS PricePO, NULL AS m_product_po_qualityrating, NULL AS RoyaltyAmt, NULL AS m_product_po_upc, NULL AS m_product_po_updated, NULL AS M_Product_PO_UpdatedBy, NULL AS m_product_po_vendorcategory, NULL AS S_ResourceAssignment_AD_Org_ID, NULL AS AssignDateFrom, NULL AS AssignDateTo, NULL AS s_resourceassignment_created, NULL AS s_resourceassignment_createby, NULL AS s_resourceassignment_isactive, NULL AS IsConfirmed, NULL AS s_resourceassignment_name, NULL AS s_resourceassignment_qty, NULL AS s_resourceassignment_s_resour, NULL AS s_resourceassignment_updated, NULL AS S_ResourceAssignment_UpdatedBy, NULL AS C_Charge_C_Org_ID, NULL AS C_Charge_C_BPartner_ID, NULL AS C_ChargeType_ID, NULL AS c_charge_chargeamt, NULL AS C_Charge_C_TaxCategory_ID, NULL AS c_charge_description, NULL AS c_charge_isactive, NULL AS IsSameCurrency, NULL AS IsSameTax, NULL AS c_charge_istaxincluded, NULL AS C_BPartner_Product_AD_Org_ID, NULL AS C_BP_Product_C_BPartner_ID, NULL AS c_bpartner_product_created, NULL AS C_BPartner_Product_CreatedBy, NULL AS c_bpartner_product_description, NULL AS c_bpartner_product_isactive, NULL AS IsManufacturer, NULL AS c_bpartner_product_manufactur, NULL AS c_bpartner_product_qualityrat, NULL AS ShelfLifeMinDays, NULL AS c_bpartner_product_shelflifem, NULL AS c_bpartner_product_updated, NULL AS C_BPartner_Product_UpdatedBy, NULL AS c_bpartner_product_vendorcate, NULL AS AcqusitionCost, NULL AS ActualLifeTimeValue, NULL AS c_bpartner_ad_language, NULL AS AD_OrgBP_ID, NULL AS C_BPartner_AD_Org_ID, NULL AS BPartner_Parent_ID, NULL AS C_BP_Group_ID, NULL AS C_Dunning_ID, NULL AS C_Greeting_ID, NULL AS C_InvoiceSchedule_ID, NULL AS C_BPartner_C_PaymentTerm_ID, NULL AS c_bpartner_created, NULL AS C_BPartner_CreatedBy, NULL AS C_BPartner_C_TaxGroup_ID, NULL AS c_bpartner_deliveryrule, NULL AS c_bpartner_deliveryviarule, NULL AS c_bpartner_description, NULL AS c_bpartner_dunninggrace, NULL AS DUNS, NULL AS c_bpartner_firstsale, NULL AS c_bpartner_flatdiscount, NULL AS c_bpartner_freightcostrule, NULL AS c_bpartner_invoicerule, NULL AS c_bpartner_isactive, NULL AS IsCustomer, NULL AS c_bpartner_isdiscountprinted, NULL AS c_bpartner_isemployee, NULL AS c_bpartner_ismanufacturer, NULL AS IsOneTime, NULL AS IsPOTaxExempt, NULL AS IsProspect, NULL AS IsSalesRep, NULL AS c_bpartner_issummary, NULL AS c_bpartner_istaxexempt, NULL AS IsVendor, NULL AS Logo_ID, NULL AS M_DiscountSchema_ID, NULL AS C_BPartner_M_PriceList_ID, NULL AS NAICS, NULL AS c_bpartner_name, NULL AS c_bpartner_name2, NULL AS NumberEmployees, NULL AS c_bpartner_paymentrule, NULL AS PaymentRulePO, NULL AS PO_DiscountSchema_ID, NULL AS PO_PaymentTerm_ID, NULL AS PO_PriceList_ID, NULL AS c_bpartner_poreference, NULL AS PotentialLifeTimeValue, NULL AS c_bpartner_rating, NULL AS c_bpartner_referenceno, NULL AS C_BPartner_SalesRep_ID, NULL AS SalesVolume, NULL AS c_bpartner_sendemail, NULL AS ShareOfCustomer, NULL AS c_bpartner_shelflifeminpct, NULL AS SO_CreditLimit, NULL AS SOCreditStatus, NULL AS SO_CreditUsed, NULL AS SO_Description, NULL AS c_bpartner_taxid, NULL AS TotalOpenBalance, NULL AS c_bpartner_updated, NULL AS C_BPartner_UpdatedBy, NULL AS c_bpartner_url, NULL AS c_bpartner_value, NULL AS C_BPartner_Location_AD_Org_ID, NULL AS c_bpartner_location_c_bpartne, NULL AS c_bpartner_location_created, NULL AS C_BPartner_Location_CreatedBy, NULL AS C_SalesRegion_ID, NULL AS c_bpartner_location_fax, NULL AS c_bpartner_location_isactive, NULL AS IsBillTo, NULL AS ISDN, NULL AS IsPayFrom, NULL AS IsRemitTo, NULL AS IsShipTo, NULL AS c_bpartner_location_name, NULL AS c_bpartner_location_phone, NULL AS c_bpartner_location_phone2, NULL AS c_bpartner_location_updated, NULL AS C_BPartner_Location_UpdatedBy, NULL AS C_Tax_AD_Org_ID, NULL AS AD_Rule_ID, NULL AS C_Country_ID, NULL AS C_Region_ID, NULL AS C_Tax_C_TaxCategory_ID, NULL AS c_tax_description, NULL AS c_tax_isactive, NULL AS c_tax_isdefault, NULL AS IsDocumentLevel, NULL AS IsSalesTax, NULL AS c_tax_issummary, NULL AS c_tax_istaxexempt, NULL AS c_tax_name, NULL AS Parent_Tax_ID, NULL AS Rate, NULL AS RequiresTaxCertificate, NULL AS SOPOType, NULL AS To_Country_ID, NULL AS C_Tax_To_Region_ID, NULL AS ValidFrom FROM c_ordertax ot JOIN c_tax t ON ot.c_tax_id = t.c_tax_id
;

-- Oct 28, 2022, 3:35:27 PM CEST
CREATE OR REPLACE VIEW C_Order_LineTax_vt(AD_Client_ID, AD_Org_ID, IsActive, Created, CreatedBy, Updated, UpdatedBy, AD_Language, C_Order_ID, C_OrderLine_ID, C_Tax_ID, TaxIndicator, C_BPartner_ID, C_BPartner_Location_ID, BPName, C_Location_ID, Line, M_Product_ID, VendorProductNo, QtyOrdered, QtyEntered, UOMSymbol, Name, Description, DocumentNote, UPC, SKU, ProductValue, ResourceDescription, PriceList, PriceEnteredList, Discount, PriceActual, PriceEntered, LineNetAmt, ProductDescription, ImageURL, C_Campaign_ID, C_Project_ID, C_Activity_ID, C_ProjectPhase_ID, C_ProjectTask_ID, C_OrderLine_AD_OrgTrx_ID, C_OrderLine_C_Charge_ID, C_OrderLine_C_Currency_ID, C_UOM_ID, DateDelivered, DateInvoiced, DateOrdered, c_orderline_datepromised, c_orderline_freightamt, IsDescription, Link_OrderLine_ID, M_Promotion_ID, C_OrderLine_M_Shipper_ID, C_OrderLine_M_Warehouse_ID, PriceCost, PriceLimit, c_orderline_processed, QtyDelivered, QtyInvoiced, QtyLostSales, QtyReserved, Ref_OrderLine_ID, RRAmt, RRStartDate, S_ResourceAssignment_ID, C_OrderLine_User1_ID, C_OrderLine_User2_ID, C_UOM_AD_Org_ID, CostingPrecision, c_uom_description, c_uom_isactive, IsDefault, c_uom_name, StdPrecision, UOMType, X12DE355, C_Order_AD_Org_ID, C_Order_AD_OrgTrx_ID, AD_User_ID, AmountRefunded, AmountTendered, Bill_BPartner_ID, Bill_Location_ID, Bill_User_ID, C_Order_C_Activity_ID, C_Order_C_BPartner_ID, C_Order_C_Campaign_ID, C_CashLine_ID, C_CashPlanLine_ID, C_Order_C_Charge_ID, C_ConversionType_ID, C_Order_C_Currency_ID, C_DocType_ID, C_DocTypeTarget_ID, ChargeAmt, CopyFrom, C_Payment_ID, C_PaymentTerm_ID, C_POS_ID, C_Order_C_Project_ID, c_order_created, C_Order_CreatedBy, DateAcct, DatePrinted, c_order_datepromised, DeliveryRule, DeliveryViaRule, c_order_description, DocAction, DocStatus, DocumentNo, DropShip_BPartner_ID, DropShip_Location_ID, DropShip_User_ID, c_order_freightamt, FreightCostRule, GrandTotal, InvoiceRule, c_order_isactive, IsApproved, IsCreditApproved, IsDelivered, c_order_isdiscountprinted, c_order_isdropship, IsInvoiced, IsPayScheduleValid, IsPrinted, IsSelected, c_order_isselfservice, IsSOTrx, IsTaxIncluded, IsTransferred, Link_Order_ID, C_Order_M_FreightCategory_ID, C_Order_M_PriceList_ID, C_Order_M_Shipper_ID, C_Order_M_Warehouse_ID, OrderType, Pay_BPartner_ID, Pay_Location_ID, c_order_paymentrule, POReference, Posted, PriorityRule, c_order_processed, ProcessedOn, PromotionCode, Ref_Order_ID, SalesRep_ID, c_order_sendemail, TotalLines, c_order_updated, C_Order_UpdatedBy, C_Order_User1_ID, C_Order_User2_ID, c_order_volume, c_order_weight, M_Product_AD_Org_ID, Classification, m_product_copyfrom, m_product_created, M_Product_CreatedBy, C_RevenueRecognition_ID, C_SubscriptionType_ID, C_TaxCategory_ID, M_Product_C_UOM_ID, DescriptionURL, m_product_discontinued, m_product_discontinuedat, Group1, Group2, GuaranteeDays, GuaranteeDaysMin, Help, m_product_isactive, IsBOM, m_product_isdropship, IsExcludeAutoDelivery, IsInvoicePrintDetails, IsPickListPrintDetails, IsPurchased, m_product_isselfservice, IsSold, IsStocked, m_product_issummary, IsVerified, IsWebStoreFeatured, LowLevel, M_AttributeSet_ID, M_AttributeSetInstance_ID, M_Product_M_FreightCategory_ID, M_Locator_ID, M_Product_Product_Category_ID, m_product_processing, ProductType, R_MailText_ID, M_Product_SalesRep_ID, S_ExpenseType_ID, ShelfDepth, ShelfHeight, ShelfWidth, S_Resource_ID, UnitsPerPack, UnitsPerPallet, m_product_updated, M_Product_UpdatedBy, VersionNo, m_product_volume, m_product_weight, M_Product_PO_AD_Org_ID, M_Product_PO_C_BPartner_ID, M_Product_PO_C_Currency_ID, CostPerOrder, m_product_po_created, M_Product_PO_CreatedBy, M_Product_PO_C_UOM_ID, DeliveryTime_Actual, DeliveryTime_Promised, m_product_po_discontinued, m_product_po_discontinuedat, m_product_po_isactive, IsCurrentVendor, m_product_po_manufacturer, M_Product_PO_M_Product_ID, Order_Min, Order_Pack, PriceEffective, PriceLastInv, PriceLastPO, m_product_po_pricelist, PricePO, m_product_po_qualityrating, RoyaltyAmt, m_product_po_upc, m_product_po_updated, M_Product_PO_UpdatedBy, m_product_po_vendorcategory, S_ResourceAssignment_AD_Org_ID, AssignDateFrom, AssignDateTo, s_resourceassignment_created, s_resourceassignment_createby, s_resourceassignment_isactive, IsConfirmed, s_resourceassignment_name, s_resourceassignment_qty, s_resourceassignment_s_resour, s_resourceassignment_updated, S_ResourceAssignment_UpdatedBy, C_Charge_C_Org_ID, C_Charge_C_BPartner_ID, C_ChargeType_ID, c_charge_chargeamt, C_Charge_C_TaxCategory_ID, c_charge_description, c_charge_isactive, IsSameCurrency, IsSameTax, c_charge_istaxincluded, C_BPartner_Product_AD_Org_ID, C_BP_Product_C_BPartner_ID, c_bpartner_product_created, C_BPartner_Product_CreatedBy, c_bpartner_product_descriptio, c_bpartner_product_isactive, IsManufacturer, c_bpartner_product_manufactur, c_bpartner_product_qualityrat, ShelfLifeMinDays, c_bpartner_product_shelflifem, c_bpartner_product_updated, C_BPartner_Product_UpdatedBy, c_bpartner_product_vendorcate, AcqusitionCost, ActualLifeTimeValue, c_bpartner_ad_language, AD_OrgBP_ID, C_BPartner_AD_Org_ID, BPartner_Parent_ID, C_BP_Group_ID, C_Dunning_ID, C_Greeting_ID, C_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, DUNS, c_bpartner_firstsale, c_bpartner_flatdiscount, c_bpartner_freightcostrule, c_bpartner_invoicerule, c_bpartner_isactive, IsCustomer, c_bpartner_isdiscountprinted, c_bpartner_isemployee, c_bpartner_ismanufacturer, IsOneTime, IsPOTaxExempt, IsProspect, IsSalesRep, c_bpartner_issummary, c_bpartner_istaxexempt, IsVendor, Logo_ID, M_DiscountSchema_ID, C_BPartner_M_PriceList_ID, NAICS, c_bpartner_name, c_bpartner_name2, NumberEmployees, c_bpartner_paymentrule, PaymentRulePO, PO_DiscountSchema_ID, PO_PaymentTerm_ID, PO_PriceList_ID, c_bpartner_poreference, PotentialLifeTimeValue, c_bpartner_rating, c_bpartner_referenceno, C_BPartner_SalesRep_ID, SalesVolume, c_bpartner_sendemail, ShareOfCustomer, c_bpartner_shelflifeminpct, SO_CreditLimit, SOCreditStatus, SO_CreditUsed, SO_Description, c_bpartner_taxid, TotalOpenBalance, c_bpartner_updated, C_BPartner_UpdatedBy, c_bpartner_url, c_bpartner_value, C_BPartner_Location_AD_Org_ID, c_bpartner_location_c_bpartne, 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, C_Tax_AD_Org_ID, AD_Rule_ID, C_Country_ID, C_Region_ID, C_Tax_C_TaxCategory_ID, c_tax_description, c_tax_isactive, c_tax_isdefault, IsDocumentLevel, IsSalesTax, c_tax_issummary, c_tax_istaxexempt, c_tax_name, Parent_Tax_ID, Rate, RequiresTaxCertificate, SOPOType, To_Country_ID, C_Tax_To_Region_ID, ValidFrom) AS SELECT ol.ad_client_id AS AD_Client_ID, ol.ad_org_id AS AD_Org_ID, ol.isactive AS IsActive, ol.created AS Created, ol.createdby AS CreatedBy, ol.updated AS Updated, ol.updatedby AS UpdatedBy, uomt.ad_language AS AD_Language, ol.c_order_id AS C_Order_ID, ol.c_orderline_id AS C_OrderLine_ID, ol.c_tax_id AS C_Tax_ID, tt.taxindicator AS TaxIndicator, ol.c_bpartner_id AS C_BPartner_ID, ol.c_bpartner_location_id AS C_BPartner_Location_ID, bp.name AS BPName, bpl.c_location_id AS C_Location_ID, ol.line AS Line, pt.m_product_id AS M_Product_ID, po.vendorproductno AS VendorProductNo, CASE WHEN ol.qtyordered <> 0 OR ol.m_product_id IS NOT NULL THEN ol.qtyordered ELSE NULL END AS QtyOrdered, CASE WHEN ol.qtyentered <> 0 OR ol.m_product_id IS NOT NULL THEN ol.qtyentered ELSE NULL END AS QtyEntered, CASE WHEN ol.qtyentered <> 0 OR ol.m_product_id IS NOT NULL THEN uomt.uomsymbol ELSE NULL END AS UOMSymbol, COALESCE(ct.name, (COALESCE(pt.name, p.name) || productattribute(ol.m_attributesetinstance_id)), ol.description) AS Name, CASE WHEN COALESCE(ct.name, pt.name, p.name) IS NOT NULL THEN ol.description ELSE NULL END AS Description, COALESCE(pt.documentnote, p.documentnote) AS DocumentNote, p.upc AS UPC, p.sku AS SKU, COALESCE(pp.vendorproductno, p.value) AS ProductValue, ra.description AS ResourceDescription, CASE WHEN i.isdiscountprinted = 'Y' AND ol.pricelist <> 0 THEN ol.pricelist ELSE NULL END AS PriceList, CASE WHEN i.isdiscountprinted = 'Y' AND ol.pricelist <> 0 AND ol.qtyentered <> 0 THEN ol.pricelist * ol.qtyordered / ol.qtyentered ELSE NULL END AS PriceEnteredList, CASE WHEN i.isdiscountprinted = 'Y' AND ol.pricelist > ol.priceactual AND ol.pricelist <> 0 THEN (ol.pricelist - ol.priceactual) / ol.pricelist * 100 ELSE NULL END AS Discount, CASE WHEN ol.priceactual <> 0 OR ol.m_product_id IS NOT NULL THEN ol.priceactual ELSE NULL END AS PriceActual, CASE WHEN ol.priceentered <> 0 OR ol.m_product_id IS NOT NULL THEN ol.priceentered ELSE NULL END AS PriceEntered, CASE WHEN ol.linenetamt <> 0 OR ol.m_product_id IS NOT NULL THEN ol.linenetamt ELSE NULL END AS LineNetAmt, pt.description AS ProductDescription, p.imageurl AS ImageURL, ol.c_campaign_id AS C_Campaign_ID, ol.c_project_id AS C_Project_ID, ol.c_activity_id AS C_Activity_ID, ol.c_projectphase_id AS C_ProjectPhase_ID, ol.c_projecttask_id AS C_ProjectTask_ID, ol.ad_orgtrx_id AS C_OrderLine_AD_OrgTrx_ID, ol.c_charge_id AS C_OrderLine_C_Charge_ID, ol.c_currency_id AS C_OrderLine_C_Currency_ID, ol.c_uom_id AS C_UOM_ID, ol.datedelivered AS DateDelivered, ol.dateinvoiced AS DateInvoiced, ol.dateordered AS DateOrdered, ol.datepromised AS c_orderline_datepromised, ol.freightamt AS c_orderline_freightamt, ol.isdescription AS IsDescription, ol.link_orderline_id AS Link_OrderLine_ID, ol.m_promotion_id AS M_Promotion_ID, ol.m_shipper_id AS C_OrderLine_M_Shipper_ID, ol.m_warehouse_id AS C_OrderLine_M_Warehouse_ID, ol.pricecost AS PriceCost, ol.pricelimit AS PriceLimit, ol.processed AS c_orderline_processed, ol.qtydelivered AS QtyDelivered, ol.qtyinvoiced AS QtyInvoiced, ol.qtylostsales AS QtyLostSales, ol.qtyreserved AS QtyReserved, ol.ref_orderline_id AS Ref_OrderLine_ID, ol.rramt AS RRAmt, ol.rrstartdate AS RRStartDate, ol.s_resourceassignment_id AS S_ResourceAssignment_ID, ol.user1_id AS C_OrderLine_User1_ID, ol.user2_id AS C_OrderLine_User2_ID, uomt.ad_org_id AS C_UOM_AD_Org_ID, uom.costingprecision AS CostingPrecision, uomt.description AS c_uom_description, uomt.isactive AS c_uom_isactive, uom.isdefault AS IsDefault, uomt.name AS c_uom_name, uom.stdprecision AS StdPrecision, uom.uomtype AS UOMType, uom.x12de355 AS X12DE355, i.ad_org_id AS C_Order_AD_Org_ID, i.ad_orgtrx_id AS C_Order_AD_OrgTrx_ID, i.ad_user_id AS AD_User_ID, i.amountrefunded AS AmountRefunded, i.amounttendered AS AmountTendered, i.bill_bpartner_id AS Bill_BPartner_ID, i.bill_location_id AS Bill_Location_ID, i.bill_user_id AS Bill_User_ID, i.c_activity_id AS C_Order_C_Activity_ID, i.c_bpartner_id AS C_Order_C_BPartner_ID, i.c_campaign_id AS C_Order_C_Campaign_ID, i.c_cashline_id AS C_CashLine_ID, i.c_cashplanline_id AS C_CashPlanLine_ID, i.c_charge_id AS C_Order_C_Charge_ID, i.c_conversiontype_id AS C_ConversionType_ID, i.c_currency_id AS C_Order_C_Currency_ID, i.c_doctype_id AS C_DocType_ID, i.c_doctypetarget_id AS C_DocTypeTarget_ID, i.chargeamt AS ChargeAmt, i.copyfrom AS CopyFrom, i.c_payment_id AS C_Payment_ID, i.c_paymentterm_id AS C_PaymentTerm_ID, i.c_pos_id AS C_POS_ID, i.c_project_id AS C_Order_C_Project_ID, i.created AS c_order_created, i.createdby AS C_Order_CreatedBy, i.dateacct AS DateAcct, i.dateprinted AS DatePrinted, i.datepromised AS c_order_datepromised, i.deliveryrule AS DeliveryRule, i.deliveryviarule AS DeliveryViaRule, i.description AS c_order_description, i.docaction AS DocAction, i.docstatus AS DocStatus, i.documentno AS DocumentNo, i.dropship_bpartner_id AS DropShip_BPartner_ID, i.dropship_location_id AS DropShip_Location_ID, i.dropship_user_id AS DropShip_User_ID, i.freightamt AS c_order_freightamt, i.freightcostrule AS FreightCostRule, i.grandtotal AS GrandTotal, i.invoicerule AS InvoiceRule, i.isactive AS c_order_isactive, i.isapproved AS IsApproved, i.iscreditapproved AS IsCreditApproved, i.isdelivered AS IsDelivered, i.isdiscountprinted AS c_order_isdiscountprinted, i.isdropship AS c_order_isdropship, i.isinvoiced AS IsInvoiced, i.ispayschedulevalid AS IsPayScheduleValid, i.isprinted AS IsPrinted, i.isselected AS IsSelected, i.isselfservice AS c_order_isselfservice, i.issotrx AS IsSOTrx, i.istaxincluded AS IsTaxIncluded, i.istransferred AS IsTransferred, i.link_order_id AS Link_Order_ID, i.m_freightcategory_id AS C_Order_M_FreightCategory_ID, i.m_pricelist_id AS C_Order_M_PriceList_ID, i.m_shipper_id AS C_Order_M_Shipper_ID, i.m_warehouse_id AS C_Order_M_Warehouse_ID, i.ordertype AS OrderType, i.pay_bpartner_id AS Pay_BPartner_ID, i.pay_location_id AS Pay_Location_ID, i.paymentrule AS c_order_paymentrule, i.poreference AS POReference, i.posted AS Posted, i.priorityrule AS PriorityRule, i.processed AS c_order_processed, i.processedon AS ProcessedOn, i.promotioncode AS PromotionCode, i.ref_order_id AS Ref_Order_ID, i.salesrep_id AS SalesRep_ID, i.sendemail AS c_order_sendemail, i.totallines AS TotalLines, i.updated AS c_order_updated, i.updatedby AS C_Order_UpdatedBy, i.user1_id AS C_Order_User1_ID, i.user2_id AS C_Order_User2_ID, i.volume AS c_order_volume, i.weight AS c_order_weight, pt.ad_org_id AS M_Product_AD_Org_ID, p.classification AS Classification, p.copyfrom AS m_product_copyfrom, pt.created AS m_product_created, pt.createdby AS M_Product_CreatedBy, p.c_revenuerecognition_id AS C_RevenueRecognition_ID, p.c_subscriptiontype_id AS C_SubscriptionType_ID, p.c_taxcategory_id AS C_TaxCategory_ID, p.c_uom_id AS M_Product_C_UOM_ID, p.descriptionurl AS DescriptionURL, p.discontinued AS m_product_discontinued, p.discontinuedat AS m_product_discontinuedat, p.group1 AS Group1, p.group2 AS Group2, p.guaranteedays AS GuaranteeDays, p.guaranteedaysmin AS GuaranteeDaysMin, p.help AS Help, pt.isactive AS m_product_isactive, p.isbom AS IsBOM, p.isdropship AS m_product_isdropship, p.isexcludeautodelivery AS IsExcludeAutoDelivery, p.isinvoiceprintdetails AS IsInvoicePrintDetails, p.ispicklistprintdetails AS IsPickListPrintDetails, p.ispurchased AS IsPurchased, p.isselfservice AS m_product_isselfservice, p.issold AS IsSold, p.isstocked AS IsStocked, p.issummary AS m_product_issummary, p.isverified AS IsVerified, p.iswebstorefeatured AS IsWebStoreFeatured, p.lowlevel AS LowLevel, p.m_attributeset_id AS M_AttributeSet_ID, p.m_attributesetinstance_id AS M_AttributeSetInstance_ID, p.m_freightcategory_id AS M_Product_M_FreightCategory_ID, p.m_locator_id AS M_Locator_ID, p.m_product_category_id AS M_Product_Product_Category_ID, p.processing AS m_product_processing, p.producttype AS ProductType, p.r_mailtext_id AS R_MailText_ID, p.salesrep_id AS M_Product_SalesRep_ID, p.s_expensetype_id AS S_ExpenseType_ID, p.shelfdepth AS ShelfDepth, p.shelfheight AS ShelfHeight, p.shelfwidth AS ShelfWidth, p.s_resource_id AS S_Resource_ID, p.unitsperpack AS UnitsPerPack, p.unitsperpallet AS UnitsPerPallet, pt.updated AS m_product_updated, pt.updatedby AS M_Product_UpdatedBy, p.versionno AS VersionNo, p.volume AS m_product_volume, p.weight AS m_product_weight, po.ad_org_id AS M_Product_PO_AD_Org_ID, po.c_bpartner_id AS M_Product_PO_C_BPartner_ID, po.c_currency_id AS M_Product_PO_C_Currency_ID, po.costperorder AS CostPerOrder, po.created AS m_product_po_created, po.createdby AS M_Product_PO_CreatedBy, po.c_uom_id AS M_Product_PO_C_UOM_ID, po.deliverytime_actual AS DeliveryTime_Actual, po.deliverytime_promised AS DeliveryTime_Promised, po.discontinued AS m_product_po_discontinued, po.discontinuedat AS m_product_po_discontinuedat, po.isactive AS m_product_po_isactive, po.iscurrentvendor AS IsCurrentVendor, po.manufacturer AS m_product_po_manufacturer, po.m_product_id AS M_Product_PO_M_Product_ID, po.order_min AS Order_Min, po.order_pack AS Order_Pack, po.priceeffective AS PriceEffective, po.pricelastinv AS PriceLastInv, po.pricelastpo AS PriceLastPO, po.pricelist AS m_product_po_pricelist, po.pricepo AS PricePO, po.qualityrating AS m_product_po_qualityrating, po.royaltyamt AS RoyaltyAmt, po.upc AS m_product_po_upc, po.updated AS m_product_po_updated, po.updatedby AS M_Product_PO_UpdatedBy, po.vendorcategory AS m_product_po_vendorcategory, ra.ad_org_id AS S_ResourceAssignment_AD_Org_ID, ra.assigndatefrom AS AssignDateFrom, ra.assigndateto AS AssignDateTo, ra.created AS s_resourceassignment_created, ra.createdby AS s_resourceassignment_createby, ra.isactive AS s_resourceassignment_isactive, ra.isconfirmed AS IsConfirmed, ra.name AS s_resourceassignment_name, ra.qty AS s_resourceassignment_qty, ra.s_resource_id AS s_resourceassignment_s_resour, ra.updated AS s_resourceassignment_updated, ra.updatedby AS S_ResourceAssignment_UpdatedBy, ct.ad_org_id AS C_Charge_C_Org_ID, c.c_bpartner_id AS C_Charge_C_BPartner_ID, c.c_chargetype_id AS C_ChargeType_ID, c.chargeamt AS c_charge_chargeamt, c.c_taxcategory_id AS C_Charge_C_TaxCategory_ID, c.description AS c_charge_description, ct.isactive AS c_charge_isactive, c.issamecurrency AS IsSameCurrency, c.issametax AS IsSameTax, c.istaxincluded AS c_charge_istaxincluded, pp.ad_org_id AS C_BPartner_Product_AD_Org_ID, pp.c_bpartner_id AS C_BP_Product_C_BPartner_ID, pp.created AS c_bpartner_product_created, pp.createdby AS C_BPartner_Product_CreatedBy, pp.description AS c_bpartner_product_descriptio, pp.isactive AS c_bpartner_product_isactive, pp.ismanufacturer AS IsManufacturer, pp.manufacturer AS c_bpartner_product_manufactur, pp.qualityrating AS c_bpartner_product_qualityrat, pp.shelflifemindays AS ShelfLifeMinDays, pp.shelflifeminpct AS c_bpartner_product_shelflifem, pp.updated AS c_bpartner_product_updated, pp.updatedby AS C_BPartner_Product_UpdatedBy, pp.vendorcategory AS c_bpartner_product_vendorcate, bp.acqusitioncost AS AcqusitionCost, bp.actuallifetimevalue AS ActualLifeTimeValue, bp.ad_language AS c_bpartner_ad_language, bp.ad_orgbp_id AS AD_OrgBP_ID, bp.ad_org_id AS C_BPartner_AD_Org_ID, bp.bpartner_parent_id AS BPartner_Parent_ID, bp.c_bp_group_id AS C_BP_Group_ID, bp.c_dunning_id AS C_Dunning_ID, bp.c_greeting_id AS C_Greeting_ID, bp.c_invoiceschedule_id AS C_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.duns AS DUNS, 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 IsCustomer, bp.isdiscountprinted AS c_bpartner_isdiscountprinted, bp.isemployee AS c_bpartner_isemployee, bp.ismanufacturer AS c_bpartner_ismanufacturer, bp.isonetime AS IsOneTime, bp.ispotaxexempt AS IsPOTaxExempt, bp.isprospect AS IsProspect, bp.issalesrep AS IsSalesRep, bp.issummary AS c_bpartner_issummary, bp.istaxexempt AS c_bpartner_istaxexempt, bp.isvendor AS IsVendor, bp.logo_id AS Logo_ID, bp.m_discountschema_id AS M_DiscountSchema_ID, bp.m_pricelist_id AS C_BPartner_M_PriceList_ID, bp.naics AS NAICS, bp.name AS c_bpartner_name, bp.name2 AS c_bpartner_name2, bp.numberemployees AS NumberEmployees, bp.paymentrule AS c_bpartner_paymentrule, bp.paymentrulepo AS PaymentRulePO, bp.po_discountschema_id AS PO_DiscountSchema_ID, bp.po_paymentterm_id AS PO_PaymentTerm_ID, bp.po_pricelist_id AS PO_PriceList_ID, bp.poreference AS c_bpartner_poreference, bp.potentiallifetimevalue AS PotentialLifeTimeValue, bp.rating AS c_bpartner_rating, bp.referenceno AS c_bpartner_referenceno, bp.salesrep_id AS C_BPartner_SalesRep_ID, bp.salesvolume AS SalesVolume, bp.sendemail AS c_bpartner_sendemail, bp.shareofcustomer AS ShareOfCustomer, bp.shelflifeminpct AS c_bpartner_shelflifeminpct, bp.so_creditlimit AS SO_CreditLimit, bp.socreditstatus AS SOCreditStatus, bp.so_creditused AS SO_CreditUsed, bp.so_description AS SO_Description, bp.taxid AS c_bpartner_taxid, bp.totalopenbalance AS TotalOpenBalance, bp.updated AS c_bpartner_updated, bp.updatedby AS C_BPartner_UpdatedBy, bp.url AS c_bpartner_url, bp.value AS c_bpartner_value, bpl.ad_org_id AS C_BPartner_Location_AD_Org_ID, bpl.c_bpartner_id AS c_bpartner_location_c_bpartne, 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, tt.ad_org_id AS C_Tax_AD_Org_ID, t.ad_rule_id AS AD_Rule_ID, t.c_country_id AS C_Country_ID, t.c_region_id AS C_Region_ID, t.c_taxcategory_id AS C_Tax_C_TaxCategory_ID, tt.description AS c_tax_description, tt.isactive AS c_tax_isactive, t.isdefault AS c_tax_isdefault, t.isdocumentlevel AS IsDocumentLevel, t.issalestax AS IsSalesTax, t.issummary AS c_tax_issummary, t.istaxexempt AS c_tax_istaxexempt, tt.name AS c_tax_name, t.parent_tax_id AS Parent_Tax_ID, t.rate AS Rate, t.requirestaxcertificate AS RequiresTaxCertificate, t.sopotype AS SOPOType, t.to_country_id AS To_Country_ID, t.to_region_id AS C_Tax_To_Region_ID, t.validfrom AS ValidFrom FROM c_orderline ol JOIN c_uom uom ON ol.c_uom_id = uom.c_uom_id JOIN c_uom_trl uomt ON ol.c_uom_id = uomt.c_uom_id JOIN c_order i ON ol.c_order_id = i.c_order_id LEFT JOIN m_product p ON ol.m_product_id = p.m_product_id LEFT JOIN m_product_trl pt ON ol.m_product_id = pt.m_product_id AND uomt.ad_language = pt.ad_language LEFT JOIN m_product_po po ON p.m_product_id = po.m_product_id AND i.c_bpartner_id = po.c_bpartner_id LEFT JOIN s_resourceassignment ra ON ol.s_resourceassignment_id = ra.s_resourceassignment_id LEFT JOIN c_charge c ON ol.c_charge_id = c.c_charge_id LEFT JOIN c_charge_trl ct ON ol.c_charge_id = ct.c_charge_id AND uomt.ad_language = ct.ad_language LEFT JOIN c_bpartner_product pp ON ol.m_product_id = pp.m_product_id AND i.c_bpartner_id = pp.c_bpartner_id JOIN c_bpartner bp ON ol.c_bpartner_id = bp.c_bpartner_id JOIN c_bpartner_location bpl ON ol.c_bpartner_location_id = bpl.c_bpartner_location_id LEFT JOIN c_tax t ON ol.c_tax_id = t.c_tax_id LEFT JOIN c_tax_trl tt ON ol.c_tax_id = tt.c_tax_id AND uomt.ad_language = tt.ad_language UNION SELECT ol.ad_client_id AS AD_Client_ID, ol.ad_org_id AS AD_Org_ID, ol.isactive AS IsActive, ol.created AS Created, ol.createdby AS CreatedBy, ol.updated AS Updated, ol.updatedby AS UpdatedBy, uomt.ad_language AS AD_Language, ol.c_order_id AS C_Order_ID, ol.c_orderline_id AS C_OrderLine_ID, ol.c_tax_id AS C_Tax_ID, NULL AS TaxIndicator, NULL AS C_BPartner_ID, NULL AS C_BPartner_Location_ID, NULL AS BPName, NULL AS C_Location_ID, ol.line + bl.line / 100 AS Line, pt.m_product_id AS M_Product_ID, po.vendorproductno AS VendorProductNo, CASE WHEN bl.isqtypercentage = 'N' THEN ol.qtyordered * bl.qtybom ELSE ol.qtyordered * (bl.qtybatch / 100) END AS QtyOrdered, CASE WHEN bl.isqtypercentage = 'N' THEN ol.qtyentered * bl.qtybom ELSE ol.qtyentered * (bl.qtybatch / 100) END AS QtyEntered, uomt.uomsymbol AS UOMSymbol, pt.name AS Name, bl.description AS Description, pt.documentnote AS DocumentNote, p.upc AS UPC, p.sku AS SKU, p.value AS ProductValue, NULL AS ResourceDescription, NULL AS PriceList, NULL AS PriceEnteredList, NULL AS Discount, NULL AS PriceActual, NULL AS PriceEntered, NULL AS LineNetAmt, pt.description AS ProductDescription, p.imageurl AS ImageURL, ol.c_campaign_id AS C_Campaign_ID, ol.c_project_id AS C_Project_ID, ol.c_activity_id AS C_Activity_ID, ol.c_projectphase_id AS C_ProjectPhase_ID, ol.c_projecttask_id AS C_ProjectTask_ID, ol.ad_orgtrx_id AS C_OrderLine_AD_OrgTrx_ID, ol.c_charge_id AS C_OrderLine_C_Charge_ID, ol.c_currency_id AS C_OrderLine_C_Currency_ID, ol.c_uom_id AS C_UOM_ID, ol.datedelivered AS DateDelivered, ol.dateinvoiced AS DateInvoiced, ol.dateordered AS DateOrdered, ol.datepromised AS c_orderline_datepromised, ol.freightamt AS c_orderline_freightamt, ol.isdescription AS IsDescription, ol.link_orderline_id AS Link_OrderLine_ID, ol.m_promotion_id AS M_Promotion_ID, ol.m_shipper_id AS C_OrderLine_M_Shipper_ID, ol.m_warehouse_id AS C_OrderLine_M_Warehouse_ID, ol.pricecost AS PriceCost, ol.pricelimit AS PriceLimit, ol.processed AS c_orderline_processed, ol.qtydelivered AS QtyDelivered, ol.qtyinvoiced AS QtyInvoiced, ol.qtylostsales AS QtyLostSales, ol.qtyreserved AS QtyReserved, ol.ref_orderline_id AS Ref_OrderLine_ID, ol.rramt AS RRAmt, ol.rrstartdate AS RRStartDate, ol.s_resourceassignment_id AS S_ResourceAssignment_ID, ol.user1_id AS C_OrderLine_User1_ID, ol.user2_id AS C_OrderLine_User2_ID, uomt.ad_org_id AS C_UOM_AD_Org_ID, uom.costingprecision AS CostingPrecision, uom.description AS c_uom_description, uomt.isactive AS c_uom_isactive, uom.isdefault AS IsDefault, uomt.name AS c_uom_name, uom.stdprecision AS StdPrecision, uom.uomtype AS UOMType, uom.x12de355 AS X12DE355, i.ad_org_id AS C_Order_AD_Org_ID, i.ad_orgtrx_id AS C_Order_AD_OrgTrx_ID, i.ad_user_id AS AD_User_ID, i.amountrefunded AS AmountRefunded, i.amounttendered AS AmountTendered, i.bill_bpartner_id AS Bill_BPartner_ID, i.bill_location_id AS Bill_Location_ID, i.bill_user_id AS Bill_User_ID, i.c_activity_id AS C_Order_C_Activity_ID, i.c_bpartner_id AS C_Order_C_BPartner_ID, i.c_campaign_id AS C_Order_C_Campaign_ID, i.c_cashline_id AS C_CashLine_ID, i.c_cashplanline_id AS C_CashPlanLine_ID, i.c_charge_id AS C_Order_C_Charge_ID, i.c_conversiontype_id AS C_ConversionType_ID, i.c_currency_id AS C_Order_C_Currency_ID, i.c_doctype_id AS C_DocType_ID, i.c_doctypetarget_id AS C_DocTypeTarget_ID, i.chargeamt AS ChargeAmt, i.copyfrom AS CopyFrom, i.c_payment_id AS C_Payment_ID, i.c_paymentterm_id AS C_PaymentTerm_ID, i.c_pos_id AS C_POS_ID, i.c_project_id AS C_Order_C_Project_ID, i.created AS c_order_created, i.createdby AS C_Order_CreatedBy, i.dateacct AS DateAcct, i.dateprinted AS DatePrinted, i.datepromised AS c_order_datepromised, i.deliveryrule AS DeliveryRule, i.deliveryviarule AS DeliveryViaRule, i.description AS c_order_description, i.docaction AS DocAction, i.docstatus AS DocStatus, i.documentno AS DocumentNo, i.dropship_bpartner_id AS DropShip_BPartner_ID, i.dropship_location_id AS DropShip_Location_ID, i.dropship_user_id AS DropShip_User_ID, i.freightamt AS c_order_freightamt, i.freightcostrule AS FreightCostRule, i.grandtotal AS GrandTotal, i.invoicerule AS InvoiceRule, i.isactive AS c_order_isactive, i.isapproved AS IsApproved, i.iscreditapproved AS IsCreditApproved, i.isdelivered AS IsDelivered, i.isdiscountprinted AS c_order_isdiscountprinted, i.isdropship AS c_order_isdropship, i.isinvoiced AS IsInvoiced, i.ispayschedulevalid AS IsPayScheduleValid, i.isprinted AS IsPrinted, i.isselected AS IsSelected, i.isselfservice AS c_order_isselfservice, i.issotrx AS IsSOTrx, i.istaxincluded AS IsTaxIncluded, i.istransferred AS IsTransferred, i.link_order_id AS Link_Order_ID, i.m_freightcategory_id AS C_Order_M_FreightCategory_ID, i.m_pricelist_id AS C_Order_M_PriceList_ID, i.m_shipper_id AS C_Order_M_Shipper_ID, i.m_warehouse_id AS C_Order_M_Warehouse_ID, i.ordertype AS OrderType, i.pay_bpartner_id AS Pay_BPartner_ID, i.pay_location_id AS Pay_Location_ID, i.paymentrule AS c_order_paymentrule, i.poreference AS POReference, i.posted AS Posted, i.priorityrule AS PriorityRule, i.processed AS c_order_processed, i.processedon AS ProcessedOn, i.promotioncode AS PromotionCode, i.ref_order_id AS Ref_Order_ID, i.salesrep_id AS SalesRep_ID, i.sendemail AS c_order_sendemail, i.totallines AS TotalLines, i.updated AS c_order_updated, i.updatedby AS C_Order_UpdatedBy, i.user1_id AS C_Order_User1_ID, i.user2_id AS C_Order_User2_ID, i.volume AS c_order_volume, i.weight AS c_order_weight, pt.ad_org_id AS M_Product_AD_Org_ID, p.classification AS Classification, p.copyfrom AS m_product_copyfrom, pt.created AS m_product_created, pt.createdby AS M_Product_CreatedBy, p.c_revenuerecognition_id AS C_RevenueRecognition_ID, p.c_subscriptiontype_id AS C_SubscriptionType_ID, p.c_taxcategory_id AS C_TaxCategory_ID, p.c_uom_id AS M_Product_C_UOM_ID, p.descriptionurl AS DescriptionURL, p.discontinued AS m_product_discontinued, p.discontinuedat AS m_product_discontinuedat, p.group1 AS Group1, p.group2 AS Group2, p.guaranteedays AS GuaranteeDays, p.guaranteedaysmin AS GuaranteeDaysMin, p.help AS Help, pt.isactive AS m_product_isactive, p.isbom AS IsBOM, p.isdropship AS m_product_isdropship, p.isexcludeautodelivery AS IsExcludeAutoDelivery, p.isinvoiceprintdetails AS IsInvoicePrintDetails, p.ispicklistprintdetails AS IsPickListPrintDetails, p.ispurchased AS IsPurchased, p.isselfservice AS m_product_isselfservice, p.issold AS IsSold, p.isstocked AS IsStocked, p.issummary AS m_product_issummary, p.isverified AS IsVerified, p.iswebstorefeatured AS IsWebStoreFeatured, p.lowlevel AS LowLevel, p.m_attributeset_id AS M_AttributeSet_ID, p.m_attributesetinstance_id AS M_AttributeSetInstance_ID, p.m_freightcategory_id AS M_Product_M_FreightCategory_ID, p.m_locator_id AS M_Locator_ID, p.m_product_category_id AS M_Product_Product_Category_ID, p.processing AS m_product_processing, p.producttype AS ProductType, p.r_mailtext_id AS R_MailText_ID, p.salesrep_id AS M_Product_SalesRep_ID, p.s_expensetype_id AS S_ExpenseType_ID, p.shelfdepth AS ShelfDepth, p.shelfheight AS ShelfHeight, p.shelfwidth AS ShelfWidth, p.s_resource_id AS S_Resource_ID, p.unitsperpack AS UnitsPerPack, p.unitsperpallet AS UnitsPerPallet, p.updated AS m_product_updated, p.updatedby AS M_Product_UpdatedBy, p.versionno AS VersionNo, p.volume AS m_product_volume, p.weight AS m_product_weight, po.ad_org_id AS M_Product_PO_AD_Org_ID, po.c_bpartner_id AS M_Product_PO_C_BPartner_ID, po.c_currency_id AS M_Product_PO_C_Currency_ID, po.costperorder AS CostPerOrder, po.created AS m_product_po_created, po.createdby AS M_Product_PO_CreatedBy, po.c_uom_id AS M_Product_PO_C_UOM_ID, po.deliverytime_actual AS DeliveryTime_Actual, po.deliverytime_promised AS DeliveryTime_Promised, po.discontinued AS m_product_po_discontinued, po.discontinuedat AS m_product_po_discontinuedat, po.isactive AS m_product_po_isactive, po.iscurrentvendor AS IsCurrentVendor, po.manufacturer AS m_product_po_manufacturer, po.m_product_id AS M_Product_PO_M_Product_ID, po.order_min AS Order_Min, po.order_pack AS Order_Pack, po.priceeffective AS PriceEffective, po.pricelastinv AS PriceLastInv, po.pricelastpo AS PriceLastPO, po.pricelist AS m_product_po_pricelist, po.pricepo AS PricePO, po.qualityrating AS m_product_po_qualityrating, po.royaltyamt AS RoyaltyAmt, po.upc AS m_product_po_upc, po.updated AS m_product_po_updated, po.updatedby AS M_Product_PO_UpdatedBy, po.vendorcategory AS m_product_po_vendorcategory, NULL AS S_ResourceAssignment_AD_Org_ID, NULL AS AssignDateFrom, NULL AS AssignDateTo, NULL AS s_resourceassignment_created, NULL AS s_resourceassignment_createby, NULL AS s_resourceassignment_isactive, NULL AS IsConfirmed, NULL AS s_resourceassignment_name, NULL AS s_resourceassignment_qty, NULL AS s_resourceassignment_s_resour, NULL AS s_resourceassignment_updated, NULL AS S_ResourceAssignment_UpdatedBy, NULL AS C_Charge_C_Org_ID, NULL AS C_Charge_C_BPartner_ID, NULL AS C_ChargeType_ID, NULL AS c_charge_chargeamt, NULL AS C_Charge_C_TaxCategory_ID, NULL AS c_charge_description, NULL AS c_charge_isactive, NULL AS IsSameCurrency, NULL AS IsSameTax, NULL AS c_charge_istaxincluded, NULL AS C_BPartner_Product_AD_Org_ID, NULL AS C_BP_Product_C_BPartner_ID, NULL AS c_bpartner_product_created, NULL AS C_BPartner_Product_CreatedBy, NULL AS c_bpartner_product_descriptio, NULL AS c_bpartner_product_isactive, NULL AS IsManufacturer, NULL AS c_bpartner_product_manufactur, NULL AS c_bpartner_product_qualityrat, NULL AS ShelfLifeMinDays, NULL AS c_bpartner_product_shelflifem, NULL AS c_bpartner_product_updated, NULL AS C_BPartner_Product_UpdatedBy, NULL AS c_bpartner_product_vendorcate, NULL AS AcqusitionCost, NULL AS ActualLifeTimeValue, NULL AS c_bpartner_ad_language, NULL AS AD_OrgBP_ID, NULL AS C_BPartner_AD_Org_ID, NULL AS BPartner_Parent_ID, NULL AS C_BP_Group_ID, NULL AS C_Dunning_ID, NULL AS C_Greeting_ID, NULL AS C_InvoiceSchedule_ID, NULL AS C_BPartner_C_PaymentTerm_ID, NULL AS c_bpartner_created, NULL AS C_BPartner_CreatedBy, NULL AS C_BPartner_C_TaxGroup_ID, NULL AS c_bpartner_deliveryrule, NULL AS c_bpartner_deliveryviarule, NULL AS c_bpartner_description, NULL AS c_bpartner_dunninggrace, NULL AS DUNS, NULL AS c_bpartner_firstsale, NULL AS c_bpartner_flatdiscount, NULL AS c_bpartner_freightcostrule, NULL AS c_bpartner_invoicerule, NULL AS c_bpartner_isactive, NULL AS IsCustomer, NULL AS c_bpartner_isdiscountprinted, NULL AS c_bpartner_isemployee, NULL AS c_bpartner_ismanufacturer, NULL AS IsOneTime, NULL AS IsPOTaxExempt, NULL AS IsProspect, NULL AS IsSalesRep, NULL AS c_bpartner_issummary, NULL AS c_bpartner_istaxexempt, NULL AS IsVendor, NULL AS Logo_ID, NULL AS M_DiscountSchema_ID, NULL AS C_BPartner_M_PriceList_ID, NULL AS NAICS, NULL AS c_bpartner_name, NULL AS c_bpartner_name2, NULL AS NumberEmployees, NULL AS c_bpartner_paymentrule, NULL AS PaymentRulePO, NULL AS PO_DiscountSchema_ID, NULL AS PO_PaymentTerm_ID, NULL AS PO_PriceList_ID, NULL AS c_bpartner_poreference, NULL AS PotentialLifeTimeValue, NULL AS c_bpartner_rating, NULL AS c_bpartner_referenceno, NULL AS C_BPartner_SalesRep_ID, NULL AS SalesVolume, NULL AS c_bpartner_sendemail, NULL AS ShareOfCustomer, NULL AS c_bpartner_shelflifeminpct, NULL AS SO_CreditLimit, NULL AS SOCreditStatus, NULL AS SO_CreditUsed, NULL AS SO_Description, NULL AS c_bpartner_taxid, NULL AS TotalOpenBalance, NULL AS c_bpartner_updated, NULL AS C_BPartner_UpdatedBy, NULL AS c_bpartner_url, NULL AS c_bpartner_value, NULL AS C_BPartner_Location_AD_Org_ID, NULL AS c_bpartner_location_c_bpartne, NULL AS c_bpartner_location_created, NULL AS C_BPartner_Location_CreatedBy, NULL AS C_SalesRegion_ID, NULL AS c_bpartner_location_fax, NULL AS c_bpartner_location_isactive, NULL AS IsBillTo, NULL AS ISDN, NULL AS IsPayFrom, NULL AS IsRemitTo, NULL AS IsShipTo, NULL AS c_bpartner_location_name, NULL AS c_bpartner_location_phone, NULL AS c_bpartner_location_phone2, NULL AS c_bpartner_location_updated, NULL AS C_BPartner_Location_UpdatedBy, NULL AS C_Tax_AD_Org_ID, NULL AS AD_Rule_ID, NULL AS C_Country_ID, NULL AS C_Region_ID, NULL AS C_Tax_C_TaxCategory_ID, NULL AS c_tax_description, NULL AS c_tax_isactive, NULL AS c_tax_isdefault, NULL AS IsDocumentLevel, NULL AS IsSalesTax, NULL AS c_tax_issummary, NULL AS c_tax_istaxexempt, NULL AS c_tax_name, NULL AS Parent_Tax_ID, NULL AS Rate, NULL AS RequiresTaxCertificate, NULL AS SOPOType, NULL AS To_Country_ID, NULL AS C_Tax_To_Region_ID, NULL AS ValidFrom FROM pp_product_bom b JOIN c_orderline ol ON b.m_product_id = ol.m_product_id JOIN c_order i ON ol.c_order_id = i.c_order_id JOIN m_product bp ON bp.m_product_id = ol.m_product_id AND bp.isbom = 'Y' AND bp.isverified = 'Y' AND bp.isinvoiceprintdetails = 'Y' JOIN pp_product_bomline bl ON bl.pp_product_bom_id = b.pp_product_bom_id JOIN m_product p ON p.m_product_id = bl.m_product_id LEFT JOIN m_product_po po ON p.m_product_id = po.m_product_id AND i.c_bpartner_id = po.c_bpartner_id JOIN c_uom uom ON ol.c_uom_id = uom.c_uom_id JOIN c_uom_trl uomt ON p.c_uom_id = uomt.c_uom_id JOIN m_product_trl pt ON pt.m_product_id = bl.m_product_id AND uomt.ad_language = pt.ad_language UNION 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, l.ad_language AS AD_Language, i.c_order_id AS C_Order_ID, NULL AS C_OrderLine_ID, NULL AS C_Tax_ID, NULL AS TaxIndicator, NULL AS C_BPartner_ID, NULL AS C_BPartner_Location_ID, NULL AS BPName, NULL AS C_Location_ID, 999998 AS Line, NULL AS M_Product_ID, NULL AS VendorProductNo, NULL AS QtyOrdered, NULL AS QtyEntered, NULL AS UOMSymbol, NULL AS Name, NULL AS Description, NULL AS DocumentNote, NULL AS UPC, NULL AS SKU, NULL AS ProductValue, NULL AS ResourceDescription, NULL AS PriceList, NULL AS PriceEnteredList, NULL AS Discount, NULL AS PriceActual, NULL AS PriceEntered, NULL AS LineNetAmt, NULL AS ProductDescription, NULL AS ImageURL, NULL AS C_Campaign_ID, NULL AS C_Project_ID, NULL AS C_Activity_ID, NULL AS C_ProjectPhase_ID, NULL AS C_ProjectTask_ID, NULL AS C_OrderLine_AD_OrgTrx_ID, NULL AS C_OrderLine_C_Charge_ID, NULL AS C_OrderLine_C_Currency_ID, NULL AS C_UOM_ID, NULL AS DateDelivered, NULL AS DateInvoiced, NULL AS DateOrdered, NULL AS c_orderline_datepromised, NULL AS c_orderline_freightamt, NULL AS IsDescription, NULL AS Link_OrderLine_ID, NULL AS M_Promotion_ID, NULL AS C_OrderLine_M_Shipper_ID, NULL AS C_OrderLine_M_Warehouse_ID, NULL AS PriceCost, NULL AS PriceLimit, NULL AS c_orderline_processed, NULL AS QtyDelivered, NULL AS QtyInvoiced, NULL AS QtyLostSales, NULL AS QtyReserved, NULL AS Ref_OrderLine_ID, NULL AS RRAmt, NULL AS RRStartDate, NULL AS S_ResourceAssignment_ID, NULL AS C_OrderLine_User1_ID, NULL AS C_OrderLine_User2_ID, NULL AS C_UOM_AD_Org_ID, NULL AS CostingPrecision, NULL AS c_uom_description, NULL AS c_uom_isactive, NULL AS IsDefault, NULL AS c_uom_name, NULL AS StdPrecision, NULL AS UOMType, NULL AS X12DE355, NULL AS C_Order_AD_Org_ID, NULL AS C_Order_AD_OrgTrx_ID, NULL AS AD_User_ID, NULL AS AmountRefunded, NULL AS AmountTendered, NULL AS Bill_BPartner_ID, NULL AS Bill_Location_ID, NULL AS Bill_User_ID, NULL AS C_Order_C_Activity_ID, NULL AS C_Order_C_BPartner_ID, NULL AS C_Order_C_Campaign_ID, NULL AS C_CashLine_ID, NULL AS C_CashPlanLine_ID, NULL AS C_Order_C_Charge_ID, NULL AS C_ConversionType_ID, NULL AS C_Order_C_Currency_ID, NULL AS C_DocType_ID, NULL AS C_DocTypeTarget_ID, NULL AS ChargeAmt, NULL AS CopyFrom, NULL AS C_Payment_ID, NULL AS C_PaymentTerm_ID, NULL AS C_POS_ID, NULL AS C_Order_C_Project_ID, NULL AS c_order_created, NULL AS C_Order_CreatedBy, NULL AS DateAcct, NULL AS DatePrinted, NULL AS c_order_datepromised, NULL AS DeliveryRule, NULL AS DeliveryViaRule, NULL AS c_order_description, NULL AS DocAction, NULL AS DocStatus, NULL AS DocumentNo, NULL AS DropShip_BPartner_ID, NULL AS DropShip_Location_ID, NULL AS DropShip_User_ID, NULL AS c_order_freightamt, NULL AS FreightCostRule, NULL AS GrandTotal, NULL AS InvoiceRule, NULL AS c_order_isactive, NULL AS IsApproved, NULL AS IsCreditApproved, NULL AS IsDelivered, NULL AS c_order_isdiscountprinted, NULL AS c_order_isdropship, NULL AS IsInvoiced, NULL AS IsPayScheduleValid, NULL AS IsPrinted, NULL AS IsSelected, NULL AS c_order_isselfservice, NULL AS IsSOTrx, NULL AS IsTaxIncluded, NULL AS IsTransferred, NULL AS Link_Order_ID, NULL AS C_Order_M_FreightCategory_ID, NULL AS C_Order_M_PriceList_ID, NULL AS C_Order_M_Shipper_ID, NULL AS C_Order_M_Warehouse_ID, NULL AS OrderType, NULL AS Pay_BPartner_ID, NULL AS Pay_Location_ID, NULL AS c_order_paymentrule, NULL AS POReference, NULL AS Posted, NULL AS PriorityRule, NULL AS c_order_processed, NULL AS ProcessedOn, NULL AS PromotionCode, NULL AS Ref_Order_ID, NULL AS SalesRep_ID, NULL AS c_order_sendemail, NULL AS TotalLines, NULL AS c_order_updated, NULL AS C_Order_UpdatedBy, NULL AS C_Order_User1_ID, NULL AS C_Order_User2_ID, NULL AS c_order_volume, NULL AS c_order_weight, NULL AS M_Product_AD_Org_ID, NULL AS Classification, NULL AS m_product_copyfrom, NULL AS m_product_created, NULL AS M_Product_CreatedBy, NULL AS C_RevenueRecognition_ID, NULL AS C_SubscriptionType_ID, NULL AS C_TaxCategory_ID, NULL AS M_Product_C_UOM_ID, NULL AS DescriptionURL, NULL AS m_product_discontinued, NULL AS m_product_discontinuedat, NULL AS Group1, NULL AS Group2, NULL AS GuaranteeDays, NULL AS GuaranteeDaysMin, NULL AS Help, NULL AS m_product_isactive, NULL AS IsBOM, NULL AS m_product_isdropship, NULL AS IsExcludeAutoDelivery, NULL AS IsInvoicePrintDetails, NULL AS IsPickListPrintDetails, NULL AS IsPurchased, NULL AS m_product_isselfservice, NULL AS IsSold, NULL AS IsStocked, NULL AS m_product_issummary, NULL AS IsVerified, NULL AS IsWebStoreFeatured, NULL AS LowLevel, NULL AS M_AttributeSet_ID, NULL AS M_AttributeSetInstance_ID, NULL AS M_Product_M_FreightCategory_ID, NULL AS M_Locator_ID, NULL AS M_Product_Product_Category_ID, NULL AS m_product_processing, NULL AS ProductType, NULL AS R_MailText_ID, NULL AS M_Product_SalesRep_ID, NULL AS S_ExpenseType_ID, NULL AS ShelfDepth, NULL AS ShelfHeight, NULL AS ShelfWidth, NULL AS S_Resource_ID, NULL AS UnitsPerPack, NULL AS UnitsPerPallet, NULL AS m_product_updated, NULL AS M_Product_UpdatedBy, NULL AS VersionNo, NULL AS m_product_volume, NULL AS m_product_weight, NULL AS M_Product_PO_AD_Org_ID, NULL AS M_Product_PO_C_BPartner_ID, NULL AS M_Product_PO_C_Currency_ID, NULL AS CostPerOrder, NULL AS m_product_po_created, NULL AS M_Product_PO_CreatedBy, NULL AS M_Product_PO_C_UOM_ID, NULL AS DeliveryTime_Actual, NULL AS DeliveryTime_Promised, NULL AS m_product_po_discontinued, NULL AS m_product_po_discontinuedat, NULL AS m_product_po_isactive, NULL AS IsCurrentVendor, NULL AS m_product_po_manufacturer, NULL AS M_Product_PO_M_Product_ID, NULL AS Order_Min, NULL AS Order_Pack, NULL AS PriceEffective, NULL AS PriceLastInv, NULL AS PriceLastPO, NULL AS m_product_po_pricelist, NULL AS PricePO, NULL AS m_product_po_qualityrating, NULL AS RoyaltyAmt, NULL AS m_product_po_upc, NULL AS m_product_po_updated, NULL AS M_Product_PO_UpdatedBy, NULL AS m_product_po_vendorcategory, NULL AS S_ResourceAssignment_AD_Org_ID, NULL AS AssignDateFrom, NULL AS AssignDateTo, NULL AS s_resourceassignment_created, NULL AS s_resourceassignment_createby, NULL AS s_resourceassignment_isactive, NULL AS IsConfirmed, NULL AS s_resourceassignment_name, NULL AS s_resourceassignment_qty, NULL AS s_resourceassignment_s_resour, NULL AS s_resourceassignment_updated, NULL AS S_ResourceAssignment_UpdatedBy, NULL AS C_Charge_C_Org_ID, NULL AS C_Charge_C_BPartner_ID, NULL AS C_ChargeType_ID, NULL AS c_charge_chargeamt, NULL AS C_Charge_C_TaxCategory_ID, NULL AS c_charge_description, NULL AS c_charge_isactive, NULL AS IsSameCurrency, NULL AS IsSameTax, NULL AS c_charge_istaxincluded, NULL AS C_BPartner_Product_AD_Org_ID, NULL AS C_BP_Product_C_BPartner_ID, NULL AS c_bpartner_product_created, NULL AS C_BPartner_Product_CreatedBy, NULL AS c_bpartner_product_descriptio, NULL AS c_bpartner_product_isactive, NULL AS IsManufacturer, NULL AS c_bpartner_product_manufactur, NULL AS c_bpartner_product_qualityrat, NULL AS ShelfLifeMinDays, NULL AS c_bpartner_product_shelflifem, NULL AS c_bpartner_product_updated, NULL AS C_BPartner_Product_UpdatedBy, NULL AS c_bpartner_product_vendorcate, NULL AS AcqusitionCost, NULL AS ActualLifeTimeValue, NULL AS c_bpartner_ad_language, NULL AS AD_OrgBP_ID, NULL AS C_BPartner_AD_Org_ID, NULL AS BPartner_Parent_ID, NULL AS C_BP_Group_ID, NULL AS C_Dunning_ID, NULL AS C_Greeting_ID, NULL AS C_InvoiceSchedule_ID, NULL AS C_BPartner_C_PaymentTerm_ID, NULL AS c_bpartner_created, NULL AS C_BPartner_CreatedBy, NULL AS C_BPartner_C_TaxGroup_ID, NULL AS c_bpartner_deliveryrule, NULL AS c_bpartner_deliveryviarule, NULL AS c_bpartner_description, NULL AS c_bpartner_dunninggrace, NULL AS DUNS, NULL AS c_bpartner_firstsale, NULL AS c_bpartner_flatdiscount, NULL AS c_bpartner_freightcostrule, NULL AS c_bpartner_invoicerule, NULL AS c_bpartner_isactive, NULL AS IsCustomer, NULL AS c_bpartner_isdiscountprinted, NULL AS c_bpartner_isemployee, NULL AS c_bpartner_ismanufacturer, NULL AS IsOneTime, NULL AS IsPOTaxExempt, NULL AS IsProspect, NULL AS IsSalesRep, NULL AS c_bpartner_issummary, NULL AS c_bpartner_istaxexempt, NULL AS IsVendor, NULL AS Logo_ID, NULL AS M_DiscountSchema_ID, NULL AS C_BPartner_M_PriceList_ID, NULL AS NAICS, NULL AS c_bpartner_name, NULL AS c_bpartner_name2, NULL AS NumberEmployees, NULL AS c_bpartner_paymentrule, NULL AS PaymentRulePO, NULL AS PO_DiscountSchema_ID, NULL AS PO_PaymentTerm_ID, NULL AS PO_PriceList_ID, NULL AS c_bpartner_poreference, NULL AS PotentialLifeTimeValue, NULL AS c_bpartner_rating, NULL AS c_bpartner_referenceno, NULL AS C_BPartner_SalesRep_ID, NULL AS SalesVolume, NULL AS c_bpartner_sendemail, NULL AS ShareOfCustomer, NULL AS c_bpartner_shelflifeminpct, NULL AS SO_CreditLimit, NULL AS SOCreditStatus, NULL AS SO_CreditUsed, NULL AS SO_Description, NULL AS c_bpartner_taxid, NULL AS TotalOpenBalance, NULL AS c_bpartner_updated, NULL AS C_BPartner_UpdatedBy, NULL AS c_bpartner_url, NULL AS c_bpartner_value, NULL AS C_BPartner_Location_AD_Org_ID, NULL AS c_bpartner_location_c_bpartne, NULL AS c_bpartner_location_created, NULL AS C_BPartner_Location_CreatedBy, NULL AS C_SalesRegion_ID, NULL AS c_bpartner_location_fax, NULL AS c_bpartner_location_isactive, NULL AS IsBillTo, NULL AS ISDN, NULL AS IsPayFrom, NULL AS IsRemitTo, NULL AS IsShipTo, NULL AS c_bpartner_location_name, NULL AS c_bpartner_location_phone, NULL AS c_bpartner_location_phone2, NULL AS c_bpartner_location_updated, NULL AS C_BPartner_Location_UpdatedBy, NULL AS C_Tax_AD_Org_ID, NULL AS AD_Rule_ID, NULL AS C_Country_ID, NULL AS C_Region_ID, NULL AS C_Tax_C_TaxCategory_ID, NULL AS c_tax_description, NULL AS c_tax_isactive, NULL AS c_tax_isdefault, NULL AS IsDocumentLevel, NULL AS IsSalesTax, NULL AS c_tax_issummary, NULL AS c_tax_istaxexempt, NULL AS c_tax_name, NULL AS Parent_Tax_ID, NULL AS Rate, NULL AS RequiresTaxCertificate, NULL AS SOPOType, NULL AS To_Country_ID, NULL AS C_Tax_To_Region_ID, NULL AS ValidFrom FROM c_order i, ad_language l WHERE l.isbaselanguage = 'N' AND l.issystemlanguage = 'Y' UNION SELECT ot.ad_client_id AS AD_Client_ID, ot.ad_org_id AS AD_Org_ID, ot.isactive AS IsActive, ot.created AS Created, ot.createdby AS CreatedBy, ot.updated AS Updated, ot.updatedby AS UpdatedBy, tt.ad_language AS AD_Language, ot.c_order_id AS C_Order_ID, NULL AS C_OrderLine_ID, ot.c_tax_id AS C_Tax_ID, tt.taxindicator AS TaxIndicator, NULL AS C_BPartner_ID, NULL AS C_BPartner_Location_ID, NULL AS BPName, NULL AS C_Location_ID, 999999 AS Line, NULL AS M_Product_ID, NULL AS VendorProductNo, NULL AS QtyOrdered, NULL AS QtyEntered, NULL AS UOMSymbol, tt.name AS Name, NULL AS Description, NULL AS DocumentNote, NULL AS UPC, NULL AS SKU, NULL AS ProductValue, NULL AS ResourceDescription, NULL AS PriceList, NULL AS PriceEnteredList, NULL AS Discount, CASE WHEN ot.istaxincluded = 'Y' THEN ot.taxamt ELSE ot.taxbaseamt END AS PriceActual, CASE WHEN ot.istaxincluded = 'Y' THEN ot.taxamt ELSE ot.taxbaseamt END AS PriceEntered, CASE WHEN ot.istaxincluded = 'Y' THEN NULL ELSE ot.taxamt END AS LineNetAmt, NULL AS ProductDescription, NULL AS ImageURL, NULL AS C_Campaign_ID, NULL AS C_Project_ID, NULL AS C_Activity_ID, NULL AS C_ProjectPhase_ID, NULL AS C_ProjectTask_ID, NULL AS C_OrderLine_AD_OrgTrx_ID, NULL AS C_OrderLine_C_Charge_ID, NULL AS C_OrderLine_C_Currency_ID, NULL AS C_UOM_ID, NULL AS DateDelivered, NULL AS DateInvoiced, NULL AS DateOrdered, NULL AS c_orderline_datepromised, NULL AS c_orderline_freightamt, NULL AS IsDescription, NULL AS Link_OrderLine_ID, NULL AS M_Promotion_ID, NULL AS C_OrderLine_M_Shipper_ID, NULL AS C_OrderLine_M_Warehouse_ID, NULL AS PriceCost, NULL AS PriceLimit, NULL AS c_orderline_processed, NULL AS QtyDelivered, NULL AS QtyInvoiced, NULL AS QtyLostSales, NULL AS QtyReserved, NULL AS Ref_OrderLine_ID, NULL AS RRAmt, NULL AS RRStartDate, NULL AS S_ResourceAssignment_ID, NULL AS C_OrderLine_User1_ID, NULL AS C_OrderLine_User2_ID, NULL AS C_UOM_AD_Org_ID, NULL AS CostingPrecision, NULL AS c_uom_description, NULL AS c_uom_isactive, NULL AS IsDefault, NULL AS c_uom_name, NULL AS StdPrecision, NULL AS UOMType, NULL AS X12DE355, NULL AS C_Order_AD_Org_ID, NULL AS C_Order_AD_OrgTrx_ID, NULL AS AD_User_ID, NULL AS AmountRefunded, NULL AS AmountTendered, NULL AS Bill_BPartner_ID, NULL AS Bill_Location_ID, NULL AS Bill_User_ID, NULL AS C_Order_C_Activity_ID, NULL AS C_Order_C_BPartner_ID, NULL AS C_Order_C_Campaign_ID, NULL AS C_CashLine_ID, NULL AS C_CashPlanLine_ID, NULL AS C_Order_C_Charge_ID, NULL AS C_ConversionType_ID, NULL AS C_Order_C_Currency_ID, NULL AS C_DocType_ID, NULL AS C_DocTypeTarget_ID, NULL AS ChargeAmt, NULL AS CopyFrom, NULL AS C_Payment_ID, NULL AS C_PaymentTerm_ID, NULL AS C_POS_ID, NULL AS C_Order_C_Project_ID, NULL AS c_order_created, NULL AS C_Order_CreatedBy, NULL AS DateAcct, NULL AS DatePrinted, NULL AS c_order_datepromised, NULL AS DeliveryRule, NULL AS DeliveryViaRule, NULL AS c_order_description, NULL AS DocAction, NULL AS DocStatus, NULL AS DocumentNo, NULL AS DropShip_BPartner_ID, NULL AS DropShip_Location_ID, NULL AS DropShip_User_ID, NULL AS c_order_freightamt, NULL AS FreightCostRule, NULL AS GrandTotal, NULL AS InvoiceRule, NULL AS c_order_isactive, NULL AS IsApproved, NULL AS IsCreditApproved, NULL AS IsDelivered, NULL AS c_order_isdiscountprinted, NULL AS c_order_isdropship, NULL AS IsInvoiced, NULL AS IsPayScheduleValid, NULL AS IsPrinted, NULL AS IsSelected, NULL AS c_order_isselfservice, NULL AS IsSOTrx, NULL AS IsTaxIncluded, NULL AS IsTransferred, NULL AS Link_Order_ID, NULL AS C_Order_M_FreightCategory_ID, NULL AS C_Order_M_PriceList_ID, NULL AS C_Order_M_Shipper_ID, NULL AS C_Order_M_Warehouse_ID, NULL AS OrderType, NULL AS Pay_BPartner_ID, NULL AS Pay_Location_ID, NULL AS c_order_paymentrule, NULL AS POReference, NULL AS Posted, NULL AS PriorityRule, NULL AS c_order_processed, NULL AS ProcessedOn, NULL AS PromotionCode, NULL AS Ref_Order_ID, NULL AS SalesRep_ID, NULL AS c_order_sendemail, NULL AS TotalLines, NULL AS c_order_updated, NULL AS C_Order_UpdatedBy, NULL AS C_Order_User1_ID, NULL AS C_Order_User2_ID, NULL AS c_order_volume, NULL AS c_order_weight, NULL AS M_Product_AD_Org_ID, NULL AS Classification, NULL AS m_product_copyfrom, NULL AS m_product_created, NULL AS M_Product_CreatedBy, NULL AS C_RevenueRecognition_ID, NULL AS C_SubscriptionType_ID, NULL AS C_TaxCategory_ID, NULL AS M_Product_C_UOM_ID, NULL AS DescriptionURL, NULL AS m_product_discontinued, NULL AS m_product_discontinuedat, NULL AS Group1, NULL AS Group2, NULL AS GuaranteeDays, NULL AS GuaranteeDaysMin, NULL AS Help, NULL AS m_product_isactive, NULL AS IsBOM, NULL AS m_product_isdropship, NULL AS IsExcludeAutoDelivery, NULL AS IsInvoicePrintDetails, NULL AS IsPickListPrintDetails, NULL AS IsPurchased, NULL AS m_product_isselfservice, NULL AS IsSold, NULL AS IsStocked, NULL AS m_product_issummary, NULL AS IsVerified, NULL AS IsWebStoreFeatured, NULL AS LowLevel, NULL AS M_AttributeSet_ID, NULL AS M_AttributeSetInstance_ID, NULL AS M_Product_M_FreightCategory_ID, NULL AS M_Locator_ID, NULL AS M_Product_Product_Category_ID, NULL AS m_product_processing, NULL AS ProductType, NULL AS R_MailText_ID, NULL AS M_Product_SalesRep_ID, NULL AS S_ExpenseType_ID, NULL AS ShelfDepth, NULL AS ShelfHeight, NULL AS ShelfWidth, NULL AS S_Resource_ID, NULL AS UnitsPerPack, NULL AS UnitsPerPallet, NULL AS m_product_updated, NULL AS M_Product_UpdatedBy, NULL AS VersionNo, NULL AS m_product_volume, NULL AS m_product_weight, NULL AS M_Product_PO_AD_Org_ID, NULL AS M_Product_PO_C_BPartner_ID, NULL AS M_Product_PO_C_Currency_ID, NULL AS CostPerOrder, NULL AS m_product_po_created, NULL AS M_Product_PO_CreatedBy, NULL AS M_Product_PO_C_UOM_ID, NULL AS DeliveryTime_Actual, NULL AS DeliveryTime_Promised, NULL AS m_product_po_discontinued, NULL AS m_product_po_discontinuedat, NULL AS m_product_po_isactive, NULL AS IsCurrentVendor, NULL AS m_product_po_manufacturer, NULL AS M_Product_PO_M_Product_ID, NULL AS Order_Min, NULL AS Order_Pack, NULL AS PriceEffective, NULL AS PriceLastInv, NULL AS PriceLastPO, NULL AS m_product_po_pricelist, NULL AS PricePO, NULL AS m_product_po_qualityrating, NULL AS RoyaltyAmt, NULL AS m_product_po_upc, NULL AS m_product_po_updated, NULL AS M_Product_PO_UpdatedBy, NULL AS m_product_po_vendorcategory, NULL AS S_ResourceAssignment_AD_Org_ID, NULL AS AssignDateFrom, NULL AS AssignDateTo, NULL AS s_resourceassignment_created, NULL AS s_resourceassignment_createby, NULL AS s_resourceassignment_isactive, NULL AS IsConfirmed, NULL AS s_resourceassignment_name, NULL AS s_resourceassignment_qty, NULL AS s_resourceassignment_s_resour, NULL AS s_resourceassignment_updated, NULL AS S_ResourceAssignment_UpdatedBy, NULL AS C_Charge_C_Org_ID, NULL AS C_Charge_C_BPartner_ID, NULL AS C_ChargeType_ID, NULL AS c_charge_chargeamt, NULL AS C_Charge_C_TaxCategory_ID, NULL AS c_charge_description, NULL AS c_charge_isactive, NULL AS IsSameCurrency, NULL AS IsSameTax, NULL AS c_charge_istaxincluded, NULL AS C_BPartner_Product_AD_Org_ID, NULL AS C_BP_Product_C_BPartner_ID, NULL AS c_bpartner_product_created, NULL AS C_BPartner_Product_CreatedBy, NULL AS c_bpartner_product_descriptio, NULL AS c_bpartner_product_isactive, NULL AS IsManufacturer, NULL AS c_bpartner_product_manufactur, NULL AS c_bpartner_product_qualityrat, NULL AS ShelfLifeMinDays, NULL AS c_bpartner_product_shelflifem, NULL AS c_bpartner_product_updated, NULL AS C_BPartner_Product_UpdatedBy, NULL AS c_bpartner_product_vendorcate, NULL AS AcqusitionCost, NULL AS ActualLifeTimeValue, NULL AS c_bpartner_ad_language, NULL AS AD_OrgBP_ID, NULL AS C_BPartner_AD_Org_ID, NULL AS BPartner_Parent_ID, NULL AS C_BP_Group_ID, NULL AS C_Dunning_ID, NULL AS C_Greeting_ID, NULL AS C_InvoiceSchedule_ID, NULL AS C_BPartner_C_PaymentTerm_ID, NULL AS c_bpartner_created, NULL AS C_BPartner_CreatedBy, NULL AS C_BPartner_C_TaxGroup_ID, NULL AS c_bpartner_deliveryrule, NULL AS c_bpartner_deliveryviarule, NULL AS c_bpartner_description, NULL AS c_bpartner_dunninggrace, NULL AS DUNS, NULL AS c_bpartner_firstsale, NULL AS c_bpartner_flatdiscount, NULL AS c_bpartner_freightcostrule, NULL AS c_bpartner_invoicerule, NULL AS c_bpartner_isactive, NULL AS IsCustomer, NULL AS c_bpartner_isdiscountprinted, NULL AS c_bpartner_isemployee, NULL AS c_bpartner_ismanufacturer, NULL AS IsOneTime, NULL AS IsPOTaxExempt, NULL AS IsProspect, NULL AS IsSalesRep, NULL AS c_bpartner_issummary, NULL AS c_bpartner_istaxexempt, NULL AS IsVendor, NULL AS Logo_ID, NULL AS M_DiscountSchema_ID, NULL AS C_BPartner_M_PriceList_ID, NULL AS NAICS, NULL AS c_bpartner_name, NULL AS c_bpartner_name2, NULL AS NumberEmployees, NULL AS c_bpartner_paymentrule, NULL AS PaymentRulePO, NULL AS PO_DiscountSchema_ID, NULL AS PO_PaymentTerm_ID, NULL AS PO_PriceList_ID, NULL AS c_bpartner_poreference, NULL AS PotentialLifeTimeValue, NULL AS c_bpartner_rating, NULL AS c_bpartner_referenceno, NULL AS C_BPartner_SalesRep_ID, NULL AS SalesVolume, NULL AS c_bpartner_sendemail, NULL AS ShareOfCustomer, NULL AS c_bpartner_shelflifeminpct, NULL AS SO_CreditLimit, NULL AS SOCreditStatus, NULL AS SO_CreditUsed, NULL AS SO_Description, NULL AS c_bpartner_taxid, NULL AS TotalOpenBalance, NULL AS c_bpartner_updated, NULL AS C_BPartner_UpdatedBy, NULL AS c_bpartner_url, NULL AS c_bpartner_value, NULL AS C_BPartner_Location_AD_Org_ID, NULL AS c_bpartner_location_c_bpartne, NULL AS c_bpartner_location_created, NULL AS C_BPartner_Location_CreatedBy, NULL AS C_SalesRegion_ID, NULL AS c_bpartner_location_fax, NULL AS c_bpartner_location_isactive, NULL AS IsBillTo, NULL AS ISDN, NULL AS IsPayFrom, NULL AS IsRemitTo, NULL AS IsShipTo, NULL AS c_bpartner_location_name, NULL AS c_bpartner_location_phone, NULL AS c_bpartner_location_phone2, NULL AS c_bpartner_location_updated, NULL AS C_BPartner_Location_UpdatedBy, NULL AS C_Tax_AD_Org_ID, NULL AS AD_Rule_ID, NULL AS C_Country_ID, NULL AS C_Region_ID, NULL AS C_Tax_C_TaxCategory_ID, NULL AS c_tax_description, NULL AS c_tax_isactive, NULL AS c_tax_isdefault, NULL AS IsDocumentLevel, NULL AS IsSalesTax, NULL AS c_tax_issummary, NULL AS c_tax_istaxexempt, NULL AS c_tax_name, NULL AS Parent_Tax_ID, NULL AS Rate, NULL AS RequiresTaxCertificate, NULL AS SOPOType, NULL AS To_Country_ID, NULL AS C_Tax_To_Region_ID, NULL AS ValidFrom FROM c_ordertax ot JOIN c_tax_trl tt ON ot.c_tax_id = tt.c_tax_id
;

