core-jgi/migration/i8.2z/postgresql/202111282319_IDEMPIERE-5059...

729 lines
828 KiB
MySQL
Raw Normal View History

-- IDEMPIERE-5059 Import the database view definition into dictionary
-- Nov 28, 2021, 11:19:13 PM CET
DROP VIEW C_Dunning_Header_v
;
-- Nov 28, 2021, 11:19:13 PM CET
DROP VIEW C_Dunning_Line_v
;
-- Nov 28, 2021, 11:19:13 PM CET
DROP VIEW C_Invoice_Header_v
;
-- Nov 28, 2021, 11:19:13 PM CET
DROP VIEW C_Invoice_LineTax_v
;
-- Nov 28, 2021, 11:19:13 PM CET
DROP VIEW C_Order_Header_v
;
-- Nov 28, 2021, 11:19:13 PM CET
DROP VIEW C_Order_LineTax_v
;
-- Nov 28, 2021, 11:19:13 PM CET
DROP VIEW C_PaySelection_Check_v
;
-- Nov 28, 2021, 11:19:13 PM CET
DROP VIEW C_PaySelection_Remittance_v
;
-- Nov 28, 2021, 11:19:13 PM CET
DROP VIEW C_Project_Details_v
;
-- Nov 28, 2021, 11:19:13 PM CET
DROP VIEW C_Project_Header_v
;
-- Nov 28, 2021, 11:19:13 PM CET
DROP VIEW C_RfQResponseLineQty_v
;
-- Nov 28, 2021, 11:19:13 PM CET
DROP VIEW C_RfQResponseLine_v
;
-- Nov 28, 2021, 11:19:13 PM CET
DROP VIEW C_RfQResponse_v
;
-- Nov 28, 2021, 11:19:13 PM CET
DROP VIEW DD_Order_Header_v
;
-- Nov 28, 2021, 11:19:13 PM CET
DROP VIEW Fact_Acct_Balance
;
-- Nov 28, 2021, 11:19:13 PM CET
DROP VIEW M_InOutConfirm_v
;
-- Nov 28, 2021, 11:19:13 PM CET
DROP VIEW M_InOut_Header_v
;
-- Nov 28, 2021, 11:19:13 PM CET
DROP VIEW M_InOut_LineConfirm_v
;
-- Nov 28, 2021, 11:19:13 PM CET
DROP VIEW M_InOut_Line_v
;
-- Nov 28, 2021, 11:19:13 PM CET
DROP VIEW PP_Order_BOM_Header_v
;
-- Nov 28, 2021, 11:19:13 PM CET
DROP VIEW PP_Order_BOMLine_v
;
-- Nov 28, 2021, 11:19:13 PM CET
DROP VIEW PP_Order_Header_v
;
-- Nov 28, 2021, 11:19:13 PM CET
DROP VIEW PP_Order_Node_v
;
-- Nov 28, 2021, 11:19:13 PM CET
DROP VIEW PP_Order_Workflow_Header_v
;
-- Nov 28, 2021, 11:19:13 PM CET
DROP VIEW PP_Product_BOMLine_v
;
-- Nov 28, 2021, 11:19:13 PM CET
DROP VIEW RV_Fact_Adaxa
;
-- Nov 28, 2021, 11:19:13 PM CET
DROP VIEW RV_Fact_Simple
;
-- Nov 28, 2021, 11:19:13 PM CET
DROP VIEW RV_PP_Order_Receipt_Issue
;
-- Nov 28, 2021, 11:19:13 PM CET
DROP VIEW RV_PP_Order_Storage
;
-- Nov 28, 2021, 11:19:13 PM CET
DROP VIEW RV_RequestUpdates_Only
;
-- Nov 28, 2021, 11:19:13 PM CET
DROP VIEW RV_Requestupdates_v
;
-- Nov 28, 2021, 11:19:13 PM CET
DROP VIEW RV_RequestUpdates
;
-- Nov 28, 2021, 11:19:13 PM CET
CREATE OR REPLACE VIEW C_Project_Header_v(AD_Client_ID, AD_Org_ID, IsActive, Created, CreatedBy, Updated, UpdatedBy, AD_Language, C_Project_ID, Value, ProjectName, Description, Note, IsSummary, ProjectCategory, Org_Location_ID, TaxID, C_ProjectType_ID, ProjectTypeName, C_Phase_ID, ProjectPhaseName, SalesRep_ID, SalesRep_Name, C_BPartner_ID, BPValue, BPTaxID, NAICS, DUNS, BPGreeting, Name, Name2, BPContactGreeting, Title, Phone, ContactName, C_Location_ID, ReferenceNo, PaymentTerm, PaymentTermNote, POReference, C_Currency_ID, M_PriceList_Version_ID, C_Campaign_ID, PlannedAmt, PlannedQty, PlannedMarginAmt, InvoicedAmt, InvoicedQty, ProjectBalanceAmt, IsCommitment, CommittedAmt, CommittedQty, DateContract, DateFinish, IsCommitCeiling, M_Warehouse_ID, Logo_ID, AD_User_ID, C_BPartner_Location_ID, CopyFrom, C_Project_C_PaymentTerm_ID, GenerateTo, c_project_processed, c_project_processing, ProjectLineLevel, ProjInvoiceRule, c_bp_acqusitioncost, c_bp_actuallifetimevalue, c_bp_ad_language, C_BP_AD_OrgBP_ID, C_BP_AD_Org_ID, C_BP_BPartner_Parent_ID, C_BP_C_BP_Group_ID, C_BP_C_Dunning_ID, C_BP_C_Greeting_ID, C_BP_C_InvoiceSchedule_ID, C_BP_C_PaymentTerm_ID, c_bp_created, C_BP_CreatedBy, C_BP_C_TaxGroup_ID, c_bp_deliveryrule, c_bp_deliveryviarule, c_bp_description, c_bp_dunninggrace, c_bp_firstsale, c_bp_flatdiscount, c_bp_freightcostrule, c_bp_invoicerule, c_bp_isactive, c_bp_iscustomer, c_bp_isdiscountprinted, c_bp_isemployee, c_bp_ismanufacturer, c_bp_isonetime, c_bp_ispotaxexempt, c_bp_isprospect, c_bp_issalesrep, c_bp_issummary, c_bp_istaxexempt, c_bp_isvendor, C_BP_Logo_ID, C_BP_M_DiscountSchema_ID, C_BP_M_PriceList_ID, c_bp_numberemployees, c_bp_paymentrule, c_bp_paymentrulepo, C_BP_PO_DiscountSchema_ID, C_BP_PO_PaymentTerm_ID, C_BP_PO_PriceList_ID, c_bp_poreference, c_bp_potentiallifetimevalue, c_bp_rating, C_BP_SalesRep_ID, c_bp_salesvolume, c_bp_sendemail, c_bp_shareofcustomer, c_bp_shelflifeminpct, c_bp_so_creditlimit, c_bp_socreditstatus, c_bp_so_creditused, c_bp_so_description, c_bp_totalopenbalance, c_bp_updated, C_BP_UpdatedBy, c_bp_url, AD_OrgInfo_AD_Org_ID, AD_OrgType_ID, C_Calendar_ID, ad_orginfo_created, AD_OrgInfo_CreatedBy, DropShip_Warehouse_ID, ad_orginfo_duns, ad_orginfo_email, ad_orginfo_fax, ad_orginfo_isactive, AD_OrgInfo_M_Warehouse_ID, Parent_Org_ID, ad_orginfo_phone, ad_orginfo_phone2, ReceiptFooterMsg, Supervisor_ID, ad_orginfo_updated, AD_OrgInfo_UpdatedBy, C_ProjectType_AD_Org_ID, c_projecttype_description, c_projecttype_help, c_projecttype_isactive, c_projecttype_projectcategory, C_Phase_AD_Org_ID, C_Phase_C_Phase_ID, C_Phase_C_ProjectType_ID, c_phase_description, c_phase_help, c_phase_isactive, C_Phase_M_Product_ID, c_phase_seqno, StandardQty, SalesRep_AD_Org_ID, SalesRep_AD_OrgTrx_ID, salesrep_ad_birthday, SalesRep_C_BPartner_ID, SalesRep_C_BP_Location_ID, SalesRep_C_Greeting_ID, salesrep_comments, salesrep_created, SalesRep_CreatedBy, salesrep_description, salesrep_email, salesrep_fax, salesrep_isactive, salesrep_lastcontact, salesrep_lastresult, salesrep_phone, salesrep_phone2, SalesRep_Supervisor_ID, salesrep_title, salesrep_updated, SalesRep_UpdatedBy, salesrep_value, salesrep_bp_acqusitioncost, salesrep_bp_actuallifevalue, salesrep_bp_ad_language, SalesRep_BP_AD_OrgBP_ID, SalesRep_BP_AD_Org_ID, SalesRep_BP_BPartner_Parent_ID, SalesRep_BP_C_BP_Group_ID, SalesRep_BP_C_Dunning_ID, SalesRep_BP_C_Greeting_ID, SalesRep_BP_C_InvoiceSched_ID, SalesRep_BP_C_PaymentTerm_ID, salesrep_bp_created, SalesRep_BP_CreatedBy, SalesRep_BP_C_TaxGroup_ID, salesrep_bp_deliveryrule, salesrep_bp_deliveryviarule, salesrep_bp_description, salesrep_bp_dunninggrace, salesrep_bp_duns, salesrep_bp_firstsale, salesrep_bp_flatdiscount, salesrep_bp_freightcostrule, salesrep_bp_invoicerule, salesrep_bp_isactive, salesrep_bp_iscustomer, salesrep_bp_isdiscountprinted, salesrep_bp_isemployee, salesrep_bp_ismanufacturer, salesrep_bp_isonetime, salesrep_bp_ispotaxexempt, salesrep_bp_isprospect, salesrep_bp_issalesrep, salesrep_bp_issummary, salesrep_bp_istaxexempt, salesrep_bp_isvendor, SalesRep_BP_Logo_ID, SalesRep_BP_M_DiscountSc
;
-- Nov 28, 2021, 11:19:13 PM CET
CREATE OR REPLACE VIEW C_Project_Details_v(AD_Client_ID, AD_Org_ID, IsActive, Created, CreatedBy, Updated, UpdatedBy, AD_Language, C_Project_ID, C_ProjectLine_ID, Line, PlannedQty, PlannedPrice, PlannedAmt, PlannedMarginAmt, CommittedAmt, M_Product_ID, Name, Description, DocumentNote, UPC, SKU, ProductValue, M_Product_Category_ID, InvoicedAmt, InvoicedQty, CommittedQty, C_Order_ID, C_OrderPO_ID, C_ProjectIssue_ID, C_ProjectPhase_ID, C_ProjectTask_ID, DoPricing, IsPrinted, c_projectline_processed, C_Project_AD_Org_ID, AD_User_ID, C_BPartner_ID, C_BPartner_Location_ID, C_BPartnerSR_ID, C_Campaign_ID, C_Currency_ID, c_project_committedamt, c_project_committedqty, c_project_copyfrom, C_PaymentTerm_ID, C_Phase_ID, C_ProjectType_ID, c_project_created, C_Project_CreatedBy, DateContract, DateFinish, c_project_description, GenerateTo, c_project_invoicedamt, c_project_invoicedqty, c_project_isactive, IsCommitCeiling, IsCommitment, c_project_issummary, M_PriceList_Version_ID, M_Warehouse_ID, c_project_name, c_project_note, c_project_plannedamt, c_project_plannedmarginamt, c_project_plannedqty, POReference, c_project_processed, c_project_processing, ProjectBalanceAmt, ProjectCategory, ProjectLineLevel, ProjInvoiceRule, C_Project_SalesRep_ID, c_project_updated, C_Project_UpdatedBy, c_project_value, M_Product_AD_Org_ID, Classification, m_product_copyfrom, m_product_created, M_Product_CreatedBy, C_RevenueRecognition_ID, C_SubscriptionType_ID, C_TaxCategory_ID, C_UOM_ID, m_product_description, DescriptionURL, Discontinued, DiscontinuedAt, Group1, Group2, GuaranteeDays, GuaranteeDaysMin, Help, ImageURL, m_product_isactive, IsDropShip, IsExcludeAutoDelivery, IsInvoicePrintDetails, IsPickListPrintDetails, IsPurchased, IsSelfService, IsSold, IsStocked, m_product_issummary, IsVerified, IsWebStoreFeatured, LowLevel, M_AttributeSet_ID, M_AttributeSetInstance_ID, M_FreightCategory_ID, M_Locator_ID, M_Product_M_Prod_Category_ID, M_Product_M_Product_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, Volume, Weight) AS SELECT pl.ad_client_id AS AD_Client_ID, pl.ad_org_id AS AD_Org_ID, pl.isactive AS IsActive, pl.created AS Created, pl.createdby AS CreatedBy, pl.updated AS Updated, pl.updatedby AS UpdatedBy, CAST('en_US' AS CHARACTER VARYING(6)) AS AD_Language, pj.c_project_id AS C_Project_ID, pl.c_projectline_id AS C_ProjectLine_ID, pl.line AS Line, pl.plannedqty AS PlannedQty, pl.plannedprice AS PlannedPrice, pl.plannedamt AS PlannedAmt, pl.plannedmarginamt AS PlannedMarginAmt, pl.committedamt AS CommittedAmt, pl.m_product_id AS M_Product_ID, COALESCE(p.name, pl.description) AS Name, CASE WHEN p.name IS NOT NULL THEN pl.description ELSE NULL END AS Description, p.documentnote AS DocumentNote, p.upc AS UPC, p.sku AS SKU, p.value AS ProductValue, pl.m_product_category_id AS M_Product_Category_ID, pl.invoicedamt AS InvoicedAmt, pl.invoicedqty AS InvoicedQty, pl.committedqty AS CommittedQty, pl.c_order_id AS C_Order_ID, pl.c_orderpo_id AS C_OrderPO_ID, pl.c_projectissue_id AS C_ProjectIssue_ID, pl.c_projectphase_id AS C_ProjectPhase_ID, pl.c_projecttask_id AS C_ProjectTask_ID, pl.dopricing AS DoPricing, pl.isprinted AS IsPrinted, pl.processed AS c_projectline_processed, pj.ad_org_id AS C_Project_AD_Org_ID, pj.ad_user_id AS AD_User_ID, pj.c_bpartner_id AS C_BPartner_ID, pj.c_bpartner_location_id AS C_BPartner_Location_ID, pj.c_bpartnersr_id AS C_BPartnerSR_ID, pj.c_campaign_id AS C_Campaign_ID, pj.c_currency_id AS C_Currency_ID, pj.committedamt AS c_project_committedamt, pj.committedqty AS c_project_committedqty, pj.copyfrom AS c_project_copyfrom, pj.c_paymentterm_id AS C_PaymentTerm_ID, pj.c_phase_id AS C_Phase_ID, pj.c_projecttype_id AS C_ProjectType_ID, pj.created AS c_project_created, pj.createdby AS C_Project_CreatedBy, pj.datecontract AS DateContract, pj.datefinish AS DateFinish, pj.description AS c_project_description, pj.generateto AS GenerateTo, pj.invoicedamt AS c_pr
;
-- Nov 28, 2021, 11:19:13 PM CET
CREATE OR REPLACE VIEW RV_Asset_Delivery(A_Asset_Delivery_ID, AD_Client_ID, AD_Org_ID, IsActive, Created, CreatedBy, Updated, UpdatedBy, A_Asset_ID, A_Asset_Group_ID, M_Product_ID, GuaranteeDate, AssetServiceDate, C_BPartner_ID, AD_User_ID, MovementDate, SerNo, Lot, VersionNo, M_InOutLine_ID, EMail, MessageID, DeliveryConfirmation, URL, Remote_Addr, Remote_Host, Referrer, Description) AS SELECT ad.a_asset_delivery_id AS A_Asset_Delivery_ID, ad.ad_client_id AS AD_Client_ID, ad.ad_org_id AS AD_Org_ID, ad.isactive AS IsActive, ad.created AS Created, ad.createdby AS CreatedBy, ad.updated AS Updated, ad.updatedby AS UpdatedBy, a.a_asset_id AS A_Asset_ID, a.a_asset_group_id AS A_Asset_Group_ID, a.m_product_id AS M_Product_ID, a.guaranteedate AS GuaranteeDate, a.assetservicedate AS AssetServiceDate, a.c_bpartner_id AS C_BPartner_ID, ad.ad_user_id AS AD_User_ID, ad.movementdate AS MovementDate, ad.serno AS SerNo, ad.lot AS Lot, ad.versionno AS VersionNo, ad.m_inoutline_id AS M_InOutLine_ID, ad.email AS EMail, ad.messageid AS MessageID, ad.deliveryconfirmation AS DeliveryConfirmation, ad.url AS URL, ad.remote_addr AS Remote_Addr, ad.remote_host AS Remote_Host, ad.referrer AS Referrer, ad.description AS Description FROM a_asset_delivery ad JOIN a_asset a ON a.a_asset_id = ad.a_asset_id
;
-- Nov 28, 2021, 11:19:13 PM CET
CREATE OR REPLACE VIEW RV_Asset_Customer(A_Asset_ID, AD_Client_ID, AD_Org_ID, IsActive, Created, CreatedBy, Updated, UpdatedBy, Value, Name, Description, Help, A_Asset_Group_ID, M_Product_ID, SerNo, Lot, VersionNo, GuaranteeDate, AssetServiceDate, C_BPartner_ID, C_BPartner_Location_ID, AD_User_ID, DeliveryCount) AS SELECT a.a_asset_id AS A_Asset_ID, a.ad_client_id AS AD_Client_ID, a.ad_org_id AS AD_Org_ID, a.isactive AS IsActive, a.created AS Created, a.createdby AS CreatedBy, a.updated AS Updated, a.updatedby AS UpdatedBy, a.value AS Value, a.name AS Name, a.description AS Description, a.help AS Help, a.a_asset_group_id AS A_Asset_Group_ID, a.m_product_id AS M_Product_ID, a.serno AS SerNo, a.lot AS Lot, a.versionno AS VersionNo, a.guaranteedate AS GuaranteeDate, a.assetservicedate AS AssetServiceDate, a.c_bpartner_id AS C_BPartner_ID, a.c_bpartner_location_id AS C_BPartner_Location_ID, a.ad_user_id AS AD_User_ID, ( SELECT count(*) AS count FROM a_asset_delivery ad WHERE a.a_asset_id = ad.a_asset_id) AS DeliveryCount FROM a_asset a WHERE a.c_bpartner_id IS NOT NULL
;
-- Nov 28, 2021, 11:19:13 PM CET
CREATE OR REPLACE VIEW RV_Transaction(M_Transaction_ID, AD_Client_ID, AD_Org_ID, MovementType, MovementDate, MovementQty, M_AttributeSetInstance_ID, M_AttributeSet_ID, SerNo, Lot, M_Lot_ID, GuaranteeDate, M_Product_ID, Value, Name, Description, UPC, SKU, C_UOM_ID, M_Product_Category_ID, Classification, Weight, Volume, VersionNo, M_Locator_ID, M_Warehouse_ID, X, Y, Z, M_InventoryLine_ID, M_Inventory_ID, M_MovementLine_ID, M_Movement_ID, M_InOutLine_ID, M_InOut_ID, M_ProductionLine_ID, M_ProductionPlan_ID, M_Production_ID, C_ProjectIssue_ID, C_Project_ID, Line, m_transaction_created, M_Transaction_CreatedBy, m_transaction_isactive, PP_Cost_Collector_ID, m_transaction_updated, M_Transction_UpdatedBy, M_Locator_AD_Org_ID, m_locator_isactive, IsDefault, PriorityNo, m_locator_value, M_Product_AD_Org_ID, m_product_copyfrom, m_product_created, M_Product_CreatedBy, C_RevenueRecognition_ID, C_SubscriptionType_ID, C_TaxCategory_ID, DescriptionURL, m_product_discontinued, m_product_discontinuedat, DocumentNote, Group1, Group2, GuaranteeDays, GuaranteeDaysMin, Help, ImageURL, m_product_isactive, IsBOM, IsDropShip, IsExcludeAutoDelivery, IsInvoicePrintDetails, IsPickListPrintDetails, IsPurchased, IsSelfService, IsSold, IsStocked, m_product_issummary, IsVerified, IsWebStoreFeatured, LowLevel, M_Product_M_AttributeSet_ID, M_Product_M_ASI_ID, M_FreightCategory_ID, M_Product_M_Locator_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, M_InventoryLine_AD_Org_ID, M_InventoryLine_C_Charge_ID, m_inventoryline_created, M_InventoryLine_CreatedBy, m_inventoryline_description, InventoryType, m_inventoryline_isactive, M_InventoryLine_M_ASI_ID, M_InventoryLine_M_Locator_ID, M_InventoryLine_M_Product_ID, m_inventoryline_processed, QtyBook, QtyCount, QtyCsv, QtyInternalUse, M_InventoryLine_RevLine_ID, m_inventoryline_updated, M_InventoryLine_UpdatedBy, M_MovementLine_AD_Org_ID, m_movementline_confirmedqty, m_movementline_created, M_MovementLine_CreatedBy, DD_OrderLine_ID, m_movementline_description, m_movementline_isactive, M_MovementLine_M_ASI_ID, M_AttributeSetInstanceTo_ID, M_MovementLine_M_Locator_ID, M_LocatorTo_ID, m_movementline_movementqty, M_MovementLine_M_Product_ID, m_movementline_processed, M_MovementLine_ReversalLn_ID, m_movementline_scrappedqty, m_movementline_targetqty, m_movementline_updated, M_MovementLine_UpdatedBy, M_InOutLine_AD_Org_ID, M_InOutLine_AD_OrgTrx_ID, M_InOutLine_C_Activity_ID, M_InOutLine_C_Campaign_ID, M_InOutLine_C_Charge_ID, m_inoutline_confirmedqty, M_InOutLine_C_OrderLine_ID, M_InOutLine_C_Project_ID, C_ProjectPhase_ID, C_ProjectTask_ID, m_inoutline_created, M_InOutLine_CreatedBy, M_InOutLine_C_UOM_ID, m_inoutline_description, m_inoutline_isactive, IsDescription, IsInvoiced, m_inoutline_line, M_InOutLine_M_ASI_ID, M_InOutLine_M_InOut_ID, m_inoutline_movementqty, M_InOutLine_M_Product_ID, M_InOutLine_M_RMALine_ID, m_inoutline_pickedqty, m_inoutline_processed, m_inoutline_qtyentered, Ref_InOutLine_ID, M_InOutLine_ReversalLine_ID, m_inoutline_scrappedqty, m_inoutline_targetqty, m_inoutline_updated, M_InOutLine_UpdatedBy, M_InOutLine_User1_ID, M_InOutLine_User2_ID, M_ProductionLine_AD_Org_ID, m_productionline_created, M_ProductionLine_CreatedBy, m_productionline_description, m_productionline_isactive, M_ProductionLine_M_ASI_ID, M_ProductionLine_M_Locator_ID, m_productionline_movementqty, M_ProductionLine_M_Product_ID, M_ProductionL_M_ProductionL_ID, m_productionline_processed, m_productionline_updated, M_ProductionLine_UpdatedBy, M_ProductionPlan_AD_Org_ID, m_productionplan_created, M_ProductionPlan_CreatedBy, m_productionplan_description, m_productionplan_isactive, m_productionplan_line, M_ProductionPlan_M_Locator_ID, M_ProductionPlan_M_Product_ID, m_productionplan_processed, m_productionplan_productionqt, m_productionplan_updated, M_ProductionPlan_UpdatedBy, C_PrjctIssue_AD_Org_ID, C_PrjctIssue_C_ProjectIssue_ID, c_prjctissue_created, C_PrjctIssue_Crea
;
-- Nov 28, 2021, 11:19:13 PM CET
CREATE OR REPLACE VIEW RV_Storage(AD_Client_ID, AD_Org_ID, M_Product_ID, Value, Name, Description, UPC, SKU, C_UOM_ID, M_Product_Category_ID, Classification, Weight, Volume, VersionNo, GuaranteeDays, GuaranteeDaysMin, M_Locator_ID, M_Warehouse_ID, X, Y, Z, QtyOnHand, QtyReserved, QtyAvailable, QtyOrdered, DateLastInventory, M_AttributeSetInstance_ID, M_AttributeSet_ID, SerNo, Lot, M_Lot_ID, GuaranteeDate, ShelfLifeDays, GoodForDays, ShelfLifeRemainingPct, m_storage_isactive, m_storage_updated, M_Storage_UpdatedBy, M_Locator_AD_Org_ID, m_locator_isactive, IsDefault, PriorityNo, m_locator_value, M_Product_AD_Org_ID, m_product_copyfrom, m_product_created, M_Product_CreatedBy, C_RevenueRecognition_ID, C_SubscriptionType_ID, C_TaxCategory_ID, DescriptionURL, m_product_discontinued, m_product_discontinuedat, DocumentNote, Group1, Group2, Help, ImageURL, m_product_isactive, IsBOM, IsDropShip, IsExcludeAutoDelivery, IsInvoicePrintDetails, IsPickListPrintDetails, IsPurchased, IsSelfService, IsSold, IsStocked, m_product_issummary, IsVerified, IsWebStoreFeatured, LowLevel, M_Product_M_AttributeSet_ID, M_Product_M_ASI_ID, M_FreightCategory_ID, M_Product_M_Locator_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, M_ASI_AD_Org_ID, m_asi_created, M_ASI_CreatedBy, M_ASI_Description, m_asi_isactive, m_asi_updated, M_ASI_UpdatedBy) AS SELECT s.ad_client_id AS AD_Client_ID, s.ad_org_id AS AD_Org_ID, s.m_product_id AS M_Product_ID, p.value AS Value, p.name AS Name, p.description AS Description, p.upc AS UPC, p.sku AS SKU, p.c_uom_id AS C_UOM_ID, p.m_product_category_id AS M_Product_Category_ID, p.classification AS Classification, p.weight AS Weight, p.volume AS Volume, p.versionno AS VersionNo, p.guaranteedays AS GuaranteeDays, p.guaranteedaysmin AS GuaranteeDaysMin, s.m_locator_id AS M_Locator_ID, l.m_warehouse_id AS M_Warehouse_ID, l.x AS X, l.y AS Y, l.z AS Z, s.qtyonhand AS QtyOnHand, s.qtyreserved AS QtyReserved, CASE WHEN COALESCE(lt.isavailableforreservation, 'Y') = 'Y' THEN s.qtyonhand ELSE 0 END - s.qtyreserved AS QtyAvailable, s.qtyordered AS QtyOrdered, s.datelastinventory AS DateLastInventory, s.m_attributesetinstance_id AS M_AttributeSetInstance_ID, asi.m_attributeset_id AS M_AttributeSet_ID, asi.serno AS SerNo, asi.lot AS Lot, asi.m_lot_id AS M_Lot_ID, asi.guaranteedate AS GuaranteeDate, daysbetween(asi.guaranteedate, statement_timestamp()) AS ShelfLifeDays, daysbetween(asi.guaranteedate, statement_timestamp()) - p.guaranteedaysmin AS GoodForDays, CASE WHEN COALESCE(p.guaranteedays, 0) > 0 THEN round(daysbetween(asi.guaranteedate, statement_timestamp()) / p.guaranteedays * 100, 0) ELSE NULL END AS ShelfLifeRemainingPct, s.isactive AS m_storage_isactive, s.updated AS m_storage_updated, s.updatedby AS M_Storage_UpdatedBy, l.ad_org_id AS M_Locator_AD_Org_ID, l.isactive AS m_locator_isactive, l.isdefault AS IsDefault, l.priorityno AS PriorityNo, l.value AS m_locator_value, p.ad_org_id AS M_Product_AD_Org_ID, p.copyfrom AS m_product_copyfrom, p.created AS m_product_created, p.createdby AS M_Product_CreatedBy, p.c_revenuerecognition_id AS C_RevenueRecognition_ID, p.c_subscriptiontype_id AS C_SubscriptionType_ID, p.c_taxcategory_id AS C_TaxCategory_ID, p.descriptionurl AS DescriptionURL, p.discontinued AS m_product_discontinued, p.discontinuedat AS m_product_discontinuedat, p.documentnote AS DocumentNote, p.group1 AS Group1, p.group2 AS Group2, p.help AS Help, p.imageurl AS ImageURL, p.isactive AS m_product_isactive, p.isbom AS IsBOM, p.isdropship AS IsDropShip, p.isexcludeautodelivery AS IsExcludeAutoDelivery, p.isinvoiceprintdetails AS IsInvoicePrintDetails, p.ispicklistprintdetails AS IsPickListPrintDetails, p.ispurchased AS IsPurchased, p.isselfservice AS 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
;
-- Nov 28, 2021, 11:19:13 PM CET
CREATE OR REPLACE VIEW RV_Click_Month(AD_Client_ID, AD_Org_ID, Name, Description, TargetURL, C_BPartner_ID, Created, Counter) AS SELECT cc.ad_client_id AS AD_Client_ID, cc.ad_org_id AS AD_Org_ID, cc.name AS Name, cc.description AS Description, cc.targeturl AS TargetURL, cc.c_bpartner_id AS C_BPartner_ID, firstof(c.created, 'MM') AS Created, count(*) AS Counter FROM w_clickcount cc JOIN w_click c ON cc.w_clickcount_id = c.w_clickcount_id WHERE cc.isactive = 'Y' GROUP BY cc.ad_client_id, cc.ad_org_id, cc.name, cc.description, cc.targeturl, cc.c_bpartner_id, (firstof(c.created, 'MM'))
;
-- Nov 28, 2021, 11:19:14 PM CET
CREATE OR REPLACE VIEW RV_UnPosted(AD_Client_ID, AD_Org_ID, Created, CreatedBy, Updated, UpdatedBy, IsActive, DocumentNo, DateDoc, DateAcct, AD_Table_ID, Record_ID, IsSOTrx, Posted, Processing, Processed, DocStatus, ProcessedOn) AS SELECT gl_journal.ad_client_id AS AD_Client_ID, gl_journal.ad_org_id AS AD_Org_ID, gl_journal.created AS Created, gl_journal.createdby AS CreatedBy, gl_journal.updated AS Updated, gl_journal.updatedby AS UpdatedBy, gl_journal.isactive AS IsActive, gl_journal.documentno AS DocumentNo, gl_journal.datedoc AS DateDoc, gl_journal.dateacct AS DateAcct, 224 AS AD_Table_ID, gl_journal.gl_journal_id AS Record_ID, 'N' AS IsSOTrx, gl_journal.posted AS Posted, gl_journal.processing AS Processing, gl_journal.processed AS Processed, gl_journal.docstatus AS DocStatus, gl_journal.processedon AS ProcessedOn FROM gl_journal WHERE gl_journal.posted <> 'Y' AND gl_journal.docstatus <> 'VO' UNION SELECT pi.ad_client_id AS AD_Client_ID, pi.ad_org_id AS AD_Org_ID, pi.created AS Created, pi.createdby AS CreatedBy, pi.updated AS Updated, pi.updatedby AS UpdatedBy, pi.isactive AS IsActive, (p.name || '_') || pi.line AS DocumentNo, pi.movementdate AS DateDoc, pi.movementdate AS DateAcct, 623 AS AD_Table_ID, pi.c_projectissue_id AS Record_ID, 'N' AS IsSOTrx, pi.posted AS Posted, pi.processing AS Processing, pi.processed AS Processed, 'CO' AS DocStatus, pi.processedon AS ProcessedOn FROM c_projectissue pi JOIN c_project p ON pi.c_project_id = p.c_project_id WHERE pi.posted <> 'Y' UNION SELECT c_invoice.ad_client_id AS AD_Client_ID, c_invoice.ad_org_id AS AD_Org_ID, c_invoice.created AS Created, c_invoice.createdby AS CreatedBy, c_invoice.updated AS Updated, c_invoice.updatedby AS UpdatedBy, c_invoice.isactive AS IsActive, c_invoice.documentno AS DocumentNo, c_invoice.dateinvoiced AS DateDoc, c_invoice.dateacct AS DateAcct, 318 AS AD_Table_ID, c_invoice.c_invoice_id AS Record_ID, c_invoice.issotrx AS IsSOTrx, c_invoice.posted AS Posted, c_invoice.processing AS Processing, c_invoice.processed AS Processed, c_invoice.docstatus AS DocStatus, c_invoice.processedon AS ProcessedOn FROM c_invoice WHERE c_invoice.posted <> 'Y' AND c_invoice.docstatus <> 'VO' UNION SELECT m_inout.ad_client_id AS AD_Client_ID, m_inout.ad_org_id AS AD_Org_ID, m_inout.created AS Created, m_inout.createdby AS CreatedBy, m_inout.updated AS Updated, m_inout.updatedby AS UpdatedBy, m_inout.isactive AS IsActive, m_inout.documentno AS DocumentNo, m_inout.movementdate AS DateDoc, m_inout.dateacct AS DateAcct, 319 AS AD_Table_ID, m_inout.m_inout_id AS Record_ID, m_inout.issotrx AS IsSOTrx, m_inout.posted AS Posted, m_inout.processing AS Processing, m_inout.processed AS Processed, m_inout.docstatus AS DocStatus, m_inout.processedon AS ProcessedOn FROM m_inout WHERE m_inout.posted <> 'Y' AND m_inout.docstatus <> 'VO' UNION SELECT m_inventory.ad_client_id AS AD_Client_ID, m_inventory.ad_org_id AS AD_Org_ID, m_inventory.created AS Created, m_inventory.createdby AS CreatedBy, m_inventory.updated AS Updated, m_inventory.updatedby AS UpdatedBy, m_inventory.isactive AS IsActive, m_inventory.documentno AS DocumentNo, m_inventory.movementdate AS DateDoc, m_inventory.movementdate AS DateAcct, 321 AS AD_Table_ID, m_inventory.m_inventory_id AS Record_ID, 'N' AS IsSOTrx, m_inventory.posted AS Posted, m_inventory.processing AS Processing, m_inventory.processed AS Processed, m_inventory.docstatus AS DocStatus, m_inventory.processedon AS ProcessedOn FROM m_inventory WHERE m_inventory.posted <> 'Y' AND m_inventory.docstatus <> 'VO' UNION SELECT m_movement.ad_client_id AS AD_Client_ID, m_movement.ad_org_id AS AD_Org_ID, m_movement.created AS Created, m_movement.createdby AS CreatedBy, m_movement.updated AS Updated, m_movement.updatedby AS UpdatedBy, m_movement.isactive AS IsActive, m_movement.documentno AS DocumentNo, m_movement.movementdate AS DateDoc, m_movement.movementdate AS DateAcct, 323 AS AD_Table_ID, m_movement.m_movement_id AS Record_ID, 'N' AS IsSOTrx, m_movement.posted AS Posted, m_movement.processing AS Processing, m_movement.processed AS Processed, m_movement.docs
;
-- Nov 28, 2021, 11:19:14 PM CET
CREATE OR REPLACE VIEW RV_ProjectCycle(AD_Client_ID, AD_Org_ID, IsActive, Created, CreatedBy, Updated, UpdatedBy, C_Cycle_ID, CycleName, C_Currency_ID, C_CycleStep_ID, CycleStepName, SeqNo, RelativeWeight, C_Phase_ID, ProjectPhaseName, C_ProjectType_ID, ProjectTypeName, ProjectValue, ProjectName, Description, Note, C_BPartner_ID, C_BPartner_Location_ID, AD_User_ID, POReference, SalesRep_ID, M_Warehouse_ID, ProjectCategory, DateContract, DateFinish, IsCommitment, IsCommitCeiling, CommittedQty, CommittedAmt, PlannedQty, PlannedAmt, PlannedMarginAmt, InvoicedAmt, InvoicedQty, ProjectBalanceAmt) AS SELECT p.ad_client_id AS AD_Client_ID, p.ad_org_id AS AD_Org_ID, p.isactive AS IsActive, p.created AS Created, p.createdby AS CreatedBy, p.updated AS Updated, p.updatedby AS UpdatedBy, c.c_cycle_id AS C_Cycle_ID, c.name AS CycleName, c.c_currency_id AS C_Currency_ID, cs.c_cyclestep_id AS C_CycleStep_ID, cs.name AS CycleStepName, cs.seqno AS SeqNo, cs.relativeweight AS RelativeWeight, pp.c_phase_id AS C_Phase_ID, pp.name AS ProjectPhaseName, pt.c_projecttype_id AS C_ProjectType_ID, pt.name AS ProjectTypeName, p.value AS ProjectValue, p.name AS ProjectName, p.description AS Description, p.note AS Note, p.c_bpartner_id AS C_BPartner_ID, p.c_bpartner_location_id AS C_BPartner_Location_ID, p.ad_user_id AS AD_User_ID, p.poreference AS POReference, p.salesrep_id AS SalesRep_ID, p.m_warehouse_id AS M_Warehouse_ID, p.projectcategory AS ProjectCategory, p.datecontract AS DateContract, p.datefinish AS DateFinish, p.iscommitment AS IsCommitment, p.iscommitceiling AS IsCommitCeiling, p.committedqty * cs.relativeweight AS CommittedQty, currencyconvert(p.committedamt, p.c_currency_id, c.c_currency_id, statement_timestamp(), 0, p.ad_client_id, p.ad_org_id) * cs.relativeweight AS CommittedAmt, p.plannedqty * cs.relativeweight AS PlannedQty, currencyconvert(p.plannedamt, p.c_currency_id, c.c_currency_id, statement_timestamp(), 0, p.ad_client_id, p.ad_org_id) * cs.relativeweight AS PlannedAmt, currencyconvert(p.plannedmarginamt, p.c_currency_id, c.c_currency_id, statement_timestamp(), 0, p.ad_client_id, p.ad_org_id) * cs.relativeweight AS PlannedMarginAmt, currencyconvert(p.invoicedamt, p.c_currency_id, c.c_currency_id, statement_timestamp(), 0, p.ad_client_id, p.ad_org_id) * cs.relativeweight AS InvoicedAmt, p.invoicedqty * cs.relativeweight AS InvoicedQty, currencyconvert(p.projectbalanceamt, p.c_currency_id, c.c_currency_id, statement_timestamp(), 0, p.ad_client_id, p.ad_org_id) * cs.relativeweight AS ProjectBalanceAmt FROM c_cycle c JOIN c_cyclestep cs ON c.c_cycle_id = cs.c_cycle_id JOIN c_cyclephase cp ON cs.c_cyclestep_id = cp.c_cyclestep_id JOIN c_phase pp ON cp.c_phase_id = pp.c_phase_id JOIN c_project p ON cp.c_phase_id = p.c_phase_id JOIN c_projecttype pt ON p.c_projecttype_id = pt.c_projecttype_id
;
-- Nov 28, 2021, 11:19:14 PM CET
CREATE OR REPLACE VIEW RV_OpenItem(AD_Org_ID, AD_Client_ID, DocumentNo, C_Invoice_ID, C_Order_ID, C_BPartner_ID, IsSOTrx, DateInvoiced, DateAcct, NetDays, DueDate, DaysDue, DiscountDate, DiscountAmt, GrandTotal, PaidAmt, OpenAmt, C_Currency_ID, C_ConversionType_ID, C_PaymentTerm_ID, IsPayScheduleValid, C_InvoicePaySchedule_ID, InvoiceCollectionType, C_Campaign_ID, C_Project_ID, C_Activity_ID, AD_OrgTrx_ID, AD_User_ID, C_BPartner_Location_ID, C_Charge_ID, C_DocType_ID, C_DocTypeTarget_ID, C_DunningLevel_ID, ChargeAmt, C_Payment_ID, Created, CreatedBy, DateOrdered, DatePrinted, Description, DocAction, DocStatus, DunningGrace, GenerateTo, IsActive, IsApproved, IsDiscountPrinted, IsInDispute, IsPaid, IsPrinted, IsSelfService, IsTaxIncluded, IsTransferred, M_PriceList_ID, M_RMA_ID, PaymentRule, POReference, Posted, ProcessedOn, Processing, Ref_Invoice_ID, Reversal_ID, SalesRep_ID, SendEMail, TotalLines, Updated, UpdatedBy, User1_ID, User2_ID) AS SELECT i.ad_org_id AS AD_Org_ID, i.ad_client_id AS AD_Client_ID, i.documentno AS DocumentNo, i.c_invoice_id AS C_Invoice_ID, i.c_order_id AS C_Order_ID, i.c_bpartner_id AS C_BPartner_ID, i.issotrx AS IsSOTrx, i.dateinvoiced AS DateInvoiced, i.dateacct AS DateAcct, p.netdays AS NetDays, paymenttermduedate(i.c_paymentterm_id, i.dateinvoiced) AS DueDate, paymenttermduedays(i.c_paymentterm_id, i.dateinvoiced, statement_timestamp()) AS DaysDue, adddays(i.dateinvoiced, p.discountdays) AS DiscountDate, currencyround(i.grandtotal * p.discount / 100, i.c_currency_id, 'N') AS DiscountAmt, i.grandtotal AS GrandTotal, invoicepaid(i.c_invoice_id, i.c_currency_id, 1) AS PaidAmt, invoiceopen(i.c_invoice_id, 0) AS OpenAmt, i.c_currency_id AS C_Currency_ID, i.c_conversiontype_id AS C_ConversionType_ID, i.c_paymentterm_id AS C_PaymentTerm_ID, i.ispayschedulevalid AS IsPayScheduleValid, NULL AS C_InvoicePaySchedule_ID, i.invoicecollectiontype AS InvoiceCollectionType, i.c_campaign_id AS C_Campaign_ID, i.c_project_id AS C_Project_ID, i.c_activity_id AS C_Activity_ID, i.c_invoice_ad_orgtrx_id AS AD_OrgTrx_ID, i.ad_user_id AS AD_User_ID, i.c_bpartner_location_id AS C_BPartner_Location_ID, i.c_charge_id AS C_Charge_ID, i.c_doctype_id AS C_DocType_ID, i.c_doctypetarget_id AS C_DocTypeTarget_ID, i.c_dunninglevel_id AS C_DunningLevel_ID, i.chargeamt AS ChargeAmt, i.c_payment_id AS C_Payment_ID, i.created AS Created, i.createdby AS CreatedBy, i.dateordered AS DateOrdered, i.dateprinted AS DatePrinted, i.description AS Description, i.docaction AS DocAction, i.docstatus AS DocStatus, i.dunninggrace AS DunningGrace, i.generateto AS GenerateTo, i.isactive AS IsActive, i.isapproved AS IsApproved, i.isdiscountprinted AS IsDiscountPrinted, i.isindispute AS IsInDispute, i.ispaid AS IsPaid, i.isprinted AS IsPrinted, i.c_invoice_isselfservice AS IsSelfService, i.istaxincluded AS IsTaxIncluded, i.istransferred AS IsTransferred, i.m_pricelist_id AS M_PriceList_ID, i.m_rma_id AS M_RMA_ID, i.paymentrule AS PaymentRule, i.poreference AS POReference, i.posted AS Posted, i.processedon AS ProcessedOn, i.processing AS Processing, i.ref_invoice_id AS Ref_Invoice_ID, i.reversal_id AS Reversal_ID, i.salesrep_id AS SalesRep_ID, i.sendemail AS SendEMail, i.totallines AS TotalLines, i.updated AS Updated, i.updatedby AS UpdatedBy, i.user1_id AS User1_ID, i.user2_id AS User2_ID FROM rv_c_invoice i JOIN c_paymentterm p ON i.c_paymentterm_id = p.c_paymentterm_id WHERE invoiceopen(i.c_invoice_id, 0) <> 0 AND i.ispayschedulevalid <> 'Y' AND (i.docstatus IN ('CO', 'CL')) UNION SELECT i.ad_org_id AS AD_Org_ID, i.ad_client_id AS AD_Client_ID, i.documentno AS DocumentNo, i.c_invoice_id AS C_Invoice_ID, i.c_order_id AS C_Order_ID, i.c_bpartner_id AS C_BPartner_ID, i.issotrx AS IsSOTrx, i.dateinvoiced AS DateInvoiced, i.dateacct AS DateAcct, daysbetween(ips.duedate, i.dateinvoiced) AS NetDays, ips.duedate AS DueDate, daysbetween(statement_timestamp(), ips.duedate) AS DaysDue, ips.discountdate AS DiscountDate, ips.discountamt AS DiscountAmt, ips.dueamt AS GrandTotal, invoicepaid(i.c_invoice_id, i.c_currency_id, 1) AS PaidAmt, invoiceopen(i.c_invoi
;
-- Nov 28, 2021, 11:19:14 PM CET
CREATE OR REPLACE VIEW RV_OrderDetail(AD_Client_ID, AD_Org_ID, IsActive, Created, CreatedBy, Updated, UpdatedBy, C_Order_ID, DocStatus, DocAction, C_DocType_ID, IsApproved, IsCreditApproved, SalesRep_ID, Bill_BPartner_ID, Bill_Location_ID, Bill_User_ID, IsDropShip, C_BPartner_ID, C_BPartner_Location_ID, AD_User_ID, POReference, C_Currency_ID, IsSOTrx, C_Campaign_ID, C_Project_ID, C_Activity_ID, C_ProjectPhase_ID, C_ProjectTask_ID, C_OrderLine_ID, DateOrdered, DatePromised, M_Product_ID, M_Warehouse_ID, M_AttributeSetInstance_ID, ProductAttribute, M_AttributeSet_ID, M_Lot_ID, GuaranteeDate, Lot, SerNo, C_UOM_ID, QtyEntered, QtyOrdered, QtyReserved, QtyDelivered, QtyInvoiced, PriceActual, PriceEntered, QtyToDeliver, QtyToInvoice, NetAmtToInvoice, QtyLostSales, AmtLostSales, Discount, Margin, MarginAmt, C_Order_AD_Org_ID, C_Order_AD_OrgTrx_ID, AmountRefunded, AmountTendered, C_Order_C_Activity_ID, C_Order_C_BPartner_ID, C_Order_C_BPartner_Loc_ID, C_Order_C_Compaign_ID, C_CashLine_ID, C_CashPlanLine_ID, C_Order_C_Charge_ID, C_ConversionType_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, c_order_dateordered, DatePrinted, c_order_datepromised, DeliveryRule, DeliveryViaRule, c_order_description, DocumentNo, DropShip_BPartner_ID, DropShip_Location_ID, DropShip_User_ID, c_order_freightamt, FreightCostRule, GrandTotal, InvoiceRule, c_order_isactive, IsDelivered, IsDiscountPrinted, IsInvoiced, IsPayScheduleValid, IsPrinted, IsSelected, IsSelfService, IsTaxIncluded, IsTransferred, Link_Order_ID, M_FreightCategory_ID, M_PriceList_ID, C_Order_M_Shipper_ID, C_Order_M_Warehouse_ID, OrderType, Pay_BPartner_ID, Pay_Location_ID, PaymentRule, Posted, PriorityRule, c_order_processed, ProcessedOn, PromotionCode, Ref_Order_ID, SendEMail, TotalLines, c_order_updated, C_Order_UpdatedBy, C_Order_User1_ID, C_Order_User2_ID, Volume, Weight, C_OrderLine_AD_OrgTrx_ID, C_OrderLine_C_Charge_ID, C_OrderLine_C_Currency_ID, C_Tax_ID, DateDelivered, DateInvoiced, c_orderline_description, c_orderline_discount, c_orderline_freightamt, IsDescription, Line, LineNetAmt, Link_OrderLine_ID, M_Promotion_ID, C_OrderLine_M_Shipper_ID, PriceCost, PriceLimit, PriceList, c_orderline_processed, Ref_OrderLine_ID, RRAmt, RRStartDate, S_ResourceAssignment_ID, C_OrderLine_User1_ID, C_OrderLine_User2_ID, M_ASI_AD_Org_ID, m_asi_created, M_ASI_CreatedBy, M_ASI_Description, m_asi_isactive, m_asi_updated, M_ASI_UpdatedBy) AS SELECT l.ad_client_id AS AD_Client_ID, l.ad_org_id AS AD_Org_ID, l.isactive AS IsActive, l.created AS Created, l.createdby AS CreatedBy, l.updated AS Updated, l.updatedby AS UpdatedBy, o.c_order_id AS C_Order_ID, o.docstatus AS DocStatus, o.docaction AS DocAction, o.c_doctype_id AS C_DocType_ID, o.isapproved AS IsApproved, o.iscreditapproved AS IsCreditApproved, o.salesrep_id AS SalesRep_ID, o.bill_bpartner_id AS Bill_BPartner_ID, o.bill_location_id AS Bill_Location_ID, o.bill_user_id AS Bill_User_ID, o.isdropship AS IsDropShip, l.c_bpartner_id AS C_BPartner_ID, l.c_bpartner_location_id AS C_BPartner_Location_ID, o.ad_user_id AS AD_User_ID, o.poreference AS POReference, o.c_currency_id AS C_Currency_ID, o.issotrx AS IsSOTrx, l.c_campaign_id AS C_Campaign_ID, l.c_project_id AS C_Project_ID, l.c_activity_id AS C_Activity_ID, l.c_projectphase_id AS C_ProjectPhase_ID, l.c_projecttask_id AS C_ProjectTask_ID, l.c_orderline_id AS C_OrderLine_ID, l.dateordered AS DateOrdered, l.datepromised AS DatePromised, l.m_product_id AS M_Product_ID, l.m_warehouse_id AS M_Warehouse_ID, l.m_attributesetinstance_id AS M_AttributeSetInstance_ID, productattribute(l.m_attributesetinstance_id) AS ProductAttribute, pasi.m_attributeset_id AS M_AttributeSet_ID, pasi.m_lot_id AS M_Lot_ID, pasi.guaranteedate AS GuaranteeDate, pasi.lot AS Lot, pasi.serno AS SerNo, l.c_uom_id AS C_UOM_ID, l.qtyentered AS QtyEntered, l.qtyordered AS QtyOrdered, l.qtyreserved AS QtyReserved, l.qtydelivered AS QtyDelivered, l.qtyinvoiced AS QtyInvoiced, l.priceactual AS PriceActual, l.priceentered AS Pr
;
-- Nov 28, 2021, 11:19:14 PM CET
CREATE OR REPLACE VIEW RV_M_Transaction_Sum(AD_Client_ID, AD_Org_ID, MovementType, M_Warehouse_ID, M_Locator_ID, M_Product_ID, MovementDate, MovementQty) AS SELECT t.ad_client_id AS AD_Client_ID, t.ad_org_id AS AD_Org_ID, t.movementtype AS MovementType, l.m_warehouse_id AS M_Warehouse_ID, t.m_locator_id AS M_Locator_ID, t.m_product_id AS M_Product_ID, t.movementdate AS MovementDate, sum(t.movementqty) AS MovementQty FROM m_transaction t, m_locator l WHERE t.m_locator_id = l.m_locator_id GROUP BY t.ad_client_id, t.ad_org_id, t.movementtype, l.m_warehouse_id, t.m_locator_id, t.m_product_id, t.movementdate
;
-- Nov 28, 2021, 11:19:14 PM CET
CREATE OR REPLACE VIEW M_InOut_Header_v(AD_Client_ID, AD_Org_ID, IsActive, Created, CreatedBy, Updated, UpdatedBy, AD_Language, M_InOut_ID, IsSOTrx, DocumentNo, DocStatus, C_DocType_ID, C_BPartner_ID, BPValue, BPTaxID, NAICS, DUNS, Org_Location_ID, TaxID, M_Warehouse_ID, Warehouse_Location_ID, DocumentType, DocumentTypeNote, C_Order_ID, MovementDate, MovementType, BPGreeting, Name, Name2, BPContactGreeting, Title, Phone, ContactName, C_Location_ID, Postal, ReferenceNo, Description, POReference, DateOrdered, Volume, Weight, M_Shipper_ID, DeliveryRule, DeliveryViaRule, PriorityRule, Logo_ID, AD_OrgTrx_ID, AD_User_ID, C_Activity_ID, C_BPartner_Location_ID, C_Campaign_ID, C_Charge_ID, ChargeAmt, C_Invoice_ID, C_Project_ID, CreateConfirm, CreateFrom, CreatePackage, DateAcct, DatePrinted, DateReceived, DocAction, DropShip_BPartner_ID, DropShip_Location_ID, DropShip_User_ID, FreightAmt, FreightCostRule, GenerateTo, IsApproved, IsDropShip, IsInDispute, m_inout_isintransit, IsPrinted, M_RMA_ID, NoPackages, PickDate, Posted, Processed, ProcessedOn, Processing, Ref_InOut_ID, Reversal_ID, M_InOut_SalesRep_ID, SendEMail, ShipDate, TrackingNo, User1_ID, User2_ID, c_bp_acqusitioncost, c_bp_actuallifetimevalue, c_bp_ad_language, C_BP_AD_OrgBP_ID, C_BP_AD_Org_ID, C_BP_BPartner_Parent_ID, C_BP_C_BP_Group_ID, C_BP_C_Dunning_ID, C_BP_C_Greeting_ID, C_BP_C_InvoiceSchedule_ID, C_BP_C_PaymentTerm_ID, c_bp_created, C_BP_CreatedBy, C_BP_C_TaxGroup_ID, c_bp_deliveryrule, c_bp_deliveryviarule, c_bp_description, c_bp_dunninggrace, c_bp_firstsale, c_bp_flatdiscount, c_bp_freightcostrule, c_bp_invoicerule, c_bp_isactive, c_bp_iscustomer, c_bp_isdiscountprinted, c_bp_isemployee, c_bp_ismanufacturer, c_bp_isonetime, c_bp_ispotaxexempt, c_bp_isprospect, c_bp_issalesrep, c_bp_issummary, c_bp_istaxexempt, c_bp_isvendor, C_BP_Logo_ID, C_BP_M_DiscountSchema_ID, C_BP_M_PriceList_ID, c_bp_numberemployees, c_bp_paymentrule, c_bp_paymentrulepo, C_BP_PO_DiscountSchema_ID, C_BP_PO_PaymentTerm_ID, C_BP_PO_PriceList_ID, c_bp_poreference, c_bp_potentiallifetimevalue, c_bp_rating, C_BP_SalesRep_ID, c_bp_salesvolume, c_bp_sendemail, c_bp_shareofcustomer, c_bp_shelflifeminpct, c_bp_so_creditlimit, c_bp_socreditstatus, c_bp_so_creditused, c_bp_so_description, c_bp_totalopenbalance, c_bp_updated, C_BP_UpdatedBy, c_bp_url, C_Greeting_AD_Org_ID, c_greeting_isactive, IsFirstNameOnly, c_greeting_name, C_BP_Location_AD_Org_ID, C_BP_Location_C_BPartner_ID, c_bp_location_created, C_BP_Location_CreatedBy, C_SalesRegion_ID, c_bp_location_fax, c_bp_location_isactive, IsBillTo, ISDN, IsPayFrom, IsRemitTo, IsShipTo, c_bp_location_name, c_bp_location_phone, c_bp_location_phone2, c_bp_location_updated, C_BP_Location_UpdatedBy, Address1, Address2, Address3, Address4, C_Location_AD_Org_ID, C_City_ID, C_Country_ID, City, c_location_created, C_Location_CreatedBy, C_Region_ID, c_location_isactive, RegionName, c_location_updated, C_Location_UpdatedBy, AD_User_AD_Org_ID, AD_User_AD_AD_OrgTrx_ID, ad_user_ad_birthday, AD_User_C_BPartner_ID, AD_User_C_BPartner_Location_ID, AD_User_C_Greeting_ID, ad_user_comments, ad_user_created, AD_User_CreatedBy, ad_user_description, ad_user_email, ad_user_fax, ad_user_isactive, ad_user_lastcontact, ad_user_lastresult, ad_user_phone2, AD_User_Supervisor_ID, ad_user_updated, AD_User_UpdatedBy, ad_user_value, C_User_Greeting_AD_Org_ID, c_user_greeting_isactive, c_user_greeting_isfnameonly, c_user_greeting_name, AD_OrgInfo_AD_Org_ID, AD_OrgType_ID, C_Calendar_ID, ad_orginfo_created, AD_OrgInfo_CreatedBy, DropShip_Warehouse_ID, ad_orginfo_duns, ad_orginfo_email, ad_orginfo_fax, ad_orginfo_isactive, AD_OrgInfo_M_Warehouse_ID, Parent_Org_ID, ad_orginfo_phone, ad_orginfo_phone2, ReceiptFooterMsg, Supervisor_ID, ad_orginfo_updated, AD_OrgInfo_UpdatedBy, M_Warehouse_AD_Org_ID, m_warehouse_description, m_warehouse__isactive, IsDisallowNegativeInv, m_warehouse_isintransit, M_WarehouseSource_ID, m_warehouse_name, ReplenishmentClass, Separator, m_warehouse_value) AS SELECT io.ad_client_id AS AD_Client_ID, io.ad_org_id AS AD_Org_ID, io.isactive AS IsActive, io.created AS
;
-- Nov 28, 2021, 11:19:14 PM CET
CREATE OR REPLACE VIEW RV_BPartnerOpen(AD_Client_ID, AD_Org_ID, IsActive, Created, CreatedBy, Updated, UpdatedBy, C_BPartner_ID, C_Currency_ID, Amt, OpenAmt, DateDoc, DaysDue, C_Campaign_ID, C_Project_ID, C_Activity_ID, AD_OrgTrx_ID, C_Charge_ID, C_ConversionType_ID, C_DocType_ID, ChargeAmt, C_Invoice_ID, C_Order_ID, C_Payment_ID, DateAcct, Description, DocStatus, DocumentNo, IsApproved, IsSelfService, Posted, ProcessedOn, Reversal_ID) AS SELECT i.ad_client_id AS AD_Client_ID, i.ad_org_id AS AD_Org_ID, i.isactive AS IsActive, i.created AS Created, i.createdby AS CreatedBy, i.updated AS Updated, i.updatedby AS UpdatedBy, i.c_bpartner_id AS C_BPartner_ID, i.c_currency_id AS C_Currency_ID, i.grandtotal * i.multiplierap AS Amt, invoiceopen(i.c_invoice_id, i.c_invoicepayschedule_id) * i.multiplierap AS OpenAmt, i.dateinvoiced AS DateDoc, COALESCE(daysbetween(statement_timestamp(), ips.duedate), paymenttermduedays(i.c_paymentterm_id, i.dateinvoiced, statement_timestamp())) AS DaysDue, i.c_campaign_id AS C_Campaign_ID, i.c_project_id AS C_Project_ID, i.c_activity_id AS C_Activity_ID, i.ad_orgtrx_id AS AD_OrgTrx_ID, i.c_charge_id AS C_Charge_ID, i.c_conversiontype_id AS C_ConversionType_ID, i.c_doctype_id AS C_DocType_ID, i.chargeamt AS ChargeAmt, i.c_invoice_id AS C_Invoice_ID, i.c_order_id AS C_Order_ID, i.c_payment_id AS C_Payment_ID, i.dateacct AS DateAcct, i.description AS Description, i.docstatus AS DocStatus, i.documentno AS DocumentNo, i.isapproved AS IsApproved, i.isselfservice AS IsSelfService, i.posted AS Posted, i.processedon AS ProcessedOn, i.reversal_id AS Reversal_ID FROM c_invoice_v i LEFT JOIN c_invoicepayschedule ips ON i.c_invoicepayschedule_id = ips.c_invoicepayschedule_id WHERE i.ispaid = 'N' AND (i.docstatus IN ('CO', 'CL')) UNION SELECT p.ad_client_id AS AD_Client_ID, p.ad_org_id AS AD_Org_ID, p.isactive AS IsActive, p.created AS Created, p.createdby AS CreatedBy, p.updated AS Updated, p.updatedby AS UpdatedBy, p.c_bpartner_id AS C_BPartner_ID, p.c_currency_id AS C_Currency_ID, p.payamt * p.multiplierap * '-1' AS Amt, paymentavailable(p.c_payment_id) * p.multiplierap * '-1' AS OpenAmt, p.datetrx AS DateDoc, NULL AS DaysDue, p.c_campaign_id AS C_Campaign_ID, p.c_project_id AS C_Project_ID, p.c_activity_id AS C_Activity_ID, p.ad_orgtrx_id AS AD_OrgTrx_ID, p.c_charge_id AS C_Charge_ID, p.c_conversiontype_id AS C_ConversionType_ID, p.c_doctype_id AS C_DocType_ID, p.chargeamt AS ChargeAmt, p.c_invoice_id AS C_Invoice_ID, p.c_order_id AS C_Order_ID, p.c_payment_id AS C_Payment_ID, p.dateacct AS DateAcct, p.description AS Description, p.docstatus AS DocStatus, p.documentno AS DocumentNo, p.isapproved AS IsApproved, p.isselfservice AS IsSelfService, p.posted AS Posted, p.processedon AS ProcessedOn, p.reversal_id AS Reversal_ID FROM c_payment_v p WHERE p.isallocated = 'N' AND p.c_bpartner_id IS NOT NULL AND (p.docstatus IN ('CO', 'CL'))
;
-- Nov 28, 2021, 11:19:14 PM CET
CREATE OR REPLACE VIEW C_Invoice_LineTax_v(AD_Client_ID, AD_Org_ID, IsActive, Created, CreatedBy, Updated, UpdatedBy, AD_Language, C_Invoice_ID, C_InvoiceLine_ID, C_Tax_ID, TaxAmt, LineTotalAmt, TaxIndicator, Line, M_Product_ID, QtyInvoiced, QtyEntered, UOMSymbol, Name, Description, DocumentNote, UPC, SKU, ProductValue, ResourceDescription, PriceList, PriceEnteredList, Discount, PriceActual, PriceEntered, LineNetAmt, M_AttributeSetInstance_ID, M_AttributeSet_ID, SerNo, Lot, M_Lot_ID, GuaranteeDate, ProductDescription, ImageURL, C_Campaign_ID, C_Project_ID, C_Activity_ID, C_ProjectPhase_ID, C_ProjectTask_ID, C_InvoiceLine_AD_OrgTrx_ID, A_Processed, C_Charge_ID, C_OrderLine_ID, C_UOM_ID, IsDescription, c_invoiceline_isprinted, M_InOutLine_ID, M_RMALine_ID, PriceLimit, c_invoiceline_processed, Ref_InvoiceLine_ID, RRAmt, RRStartDate, S_ResourceAssignment_ID, C_InvoiceLine_User1_ID, C_InvoiceLine_User2_ID, C_UOM_AD_Org_ID, CostingPrecision, c_uom_description, c_uom_isactive, c_uom_isdefault, c_uom_name, StdPrecision, UOMType, X12DE355, C_Invoice_AD_Org_ID, C_Invoice_AD_OrgTrx_ID, C_Invoice_AD_User_ID, C_Invoice_C_Activity_ID, C_Invoice_C_BPartner_ID, C_BPartner_Location_ID, C_Invoice_C_Campaign_ID, C_Invoice_C_Charge_ID, C_ConversionType_ID, C_Currency_ID, C_DocType_ID, C_DocTypeTarget_ID, C_DunningLevel_ID, c_invoice_chargeamt, C_Order_ID, C_Payment_ID, C_PaymentTerm_ID, C_Invoice_C_Project_ID, c_invoice_created, C_Invoice_CreatedBy, DateAcct, DateInvoiced, DateOrdered, DatePrinted, c_invoice_description, DocAction, DocStatus, DocumentNo, DunningGrace, GenerateTo, GrandTotal, InvoiceCollectionType, c_invoice_isactive, IsApproved, IsDiscountPrinted, IsInDispute, IsPaid, IsPayScheduleValid, c_invoice_isprinted, c_invoice_isselfservice, IsSOTrx, c_invoice_istaxincluded, IsTransferred, M_PriceList_ID, M_RMA_ID, PaymentRule, POReference, Posted, ProcessedOn, Processing, Ref_Invoice_ID, Reversal_ID, SalesRep_ID, SendEMail, TotalLines, c_invoice_updated, C_Invoice_UpdatedBy, C_Invoice_User1_ID, C_Invoice_User2_ID, 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, IsTaxExempt, c_tax_name, Parent_Tax_ID, Rate, RequiresTaxCertificate, SOPOType, To_Country_ID, To_Region_ID, ValidFrom, M_Product_AD_Org_ID, Classification, m_product_copyfrom, m_product_created, M_Product_CreatedBy, C_RevenueRecognition_ID, C_SubscriptionType_ID, M_Product_C_TaxCategory_ID, DescriptionURL, Discontinued, DiscontinuedAt, Group1, Group2, GuaranteeDays, GuaranteeDaysMin, Help, m_product_isactive, IsBOM, IsDropShip, IsExcludeAutoDelivery, IsInvoicePrintDetails, IsPickListPrintDetails, IsPurchased, m_product_isselfservice, IsSold, IsStocked, m_product_issummary, IsVerified, IsWebStoreFeatured, LowLevel, M_Product_M_AttributeSet_ID, M_Product_M_ASI_ID, M_FreightCategory_ID, M_Locator_ID, M_Product_M_Prod_Category_ID, m_product_processing, ProductType, R_MailText_ID, M_Product_SalesRep_ID, S_ExpenseType_ID, ShelfDepth, ShelfHeight, ShelfWidth, M_Product_S_Resource_ID, UnitsPerPack, UnitsPerPallet, m_product_updated, M_Product_UpdatedBy, VersionNo, Volume, Weight, C_Charge_AD_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_BP_Product_AD_Org_ID, C_BP_Product_C_BPartner_ID, c_bp_product_created, C_BP_Product_CreatedBy, c_bp_product_description, c_bp_product_isactive, IsManufacturer, Manufacturer, QualityRating, ShelfLifeMinDays, ShelfLifeMinPct, c_bp_product_updated, C_BP_Product_UpdatedBy, VendorCategory, S_RAssignment_AD_Org_ID, AssignDateFrom, AssignDateTo, s_rassignment_created, s_rassignment_createby, s_rassignment_isactive, IsConfirmed, s_rassignment_name, s_rassignment_qty, S_RAssignment_S_Resource_ID, s_rassignment_updated, S_RAssignment_UpdatedBy, M_ASI_AD_Org_ID, m_asi_created, M_ASI_CreatedBy, M_ASI_Description, m_asi_isactive, m_asi_updated, M_ASI_UpdatedBy) AS SELECT il.ad_client_id AS A
;
-- Nov 28, 2021, 11:19:14 PM CET
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_ResourceAssignme
;
-- Nov 28, 2021, 11:19:14 PM CET
CREATE OR REPLACE VIEW RV_M_Requisition(M_Requisition_ID, AD_Client_ID, AD_Org_ID, IsActive, Created, CreatedBy, Updated, UpdatedBy, DocumentNo, Description, Help, AD_User_ID, M_PriceList_ID, M_Warehouse_ID, IsApproved, PriorityRule, DateRequired, TotalLines, DocAction, DocStatus, Processed, M_RequisitionLine_ID, Line, Qty, QtyOrdered, M_Product_ID, LineDescription, PriceActual, LineNetAmt, C_Charge_ID) AS SELECT r.m_requisition_id AS M_Requisition_ID, r.ad_client_id AS AD_Client_ID, r.ad_org_id AS AD_Org_ID, r.isactive AS IsActive, r.created AS Created, r.createdby AS CreatedBy, r.updated AS Updated, r.updatedby AS UpdatedBy, r.documentno AS DocumentNo, r.description AS Description, r.help AS Help, r.ad_user_id AS AD_User_ID, r.m_pricelist_id AS M_PriceList_ID, r.m_warehouse_id AS M_Warehouse_ID, r.isapproved AS IsApproved, r.priorityrule AS PriorityRule, r.daterequired AS DateRequired, r.totallines AS TotalLines, r.docaction AS DocAction, r.docstatus AS DocStatus, r.processed AS Processed, l.m_requisitionline_id AS M_RequisitionLine_ID, l.line AS Line, l.qty AS Qty, CASE WHEN l.c_orderline_id IS NOT NULL THEN l.qty ELSE 0 END AS QtyOrdered, l.m_product_id AS M_Product_ID, l.description AS LineDescription, l.priceactual AS PriceActual, l.linenetamt AS LineNetAmt, l.c_charge_id AS C_Charge_ID FROM m_requisition r JOIN m_requisitionline l ON r.m_requisition_id = l.m_requisition_id
;
-- Nov 28, 2021, 11:19:14 PM CET
CREATE OR REPLACE VIEW C_Dunning_Header_v(AD_Client_ID, AD_Org_ID, IsActive, Created, CreatedBy, Updated, UpdatedBy, AD_Language, C_DunningRun_ID, C_DunningRunEntry_ID, DunningDate, PrintName, DocumentNote, C_BPartner_ID, BPValue, BPTaxID, NAICS, DUNS, Org_Location_ID, TaxID, SalesRep_ID, SalesRep_Name, BPGreeting, Name, Name2, BPContactGreeting, Title, Phone, ContactName, C_Location_ID, ReferenceNo, Postal, Amt, Qty, Note, Logo_ID, C_Dunning_ID, C_DunningRun_C_DunningLevel_ID, c_dunningrun_description, Processed, Processing, SendIt, C_DunningRunEntry_AD_Org_ID, AD_User_ID, C_BPartner_Location_ID, C_Currency_ID, C_DunRunEntry_C_DunLevel_ID, c_dunningrunentry_created, C_DunningRunEntry_CreatedBy, c_dunningrunentry_isactive, c_dunningrunentry_processed, c_dunningrunentry_updated, C_DunningRunEntry_UpdatedBy, C_DunningLevel_AD_Org_ID, C_DunningLevel_C_Dunning_ID, ChargeFee, ChargeInterest, C_PaymentTerm_ID, DaysAfterDue, DaysBetweenDunning, c_dunninglevel_description, Dunning_PrintFormat_ID, FeeAmt, InterestPercent, InvoiceCollectionType, c_dunninglevel_isactive, IsSetCreditStop, IsSetPaymentTerm, IsShowAllDue, IsShowNotDue, IsStatement, c_dunninglevel_name, c_bpartner_acqusitioncost, c_bpartner_actuallifetimevalue, c_bpartner_ad_language, C_BPartner_AD_OrgBP_ID, C_BPartner_AD_Org_ID, C_BPartner_BPartner_Parent_ID, C_BPartner_C_BP_Group_ID, C_BPartner_C_Greeting_ID, C_BPartner_InvoiceSchedule_ID, C_BPartner_C_PaymentTerm_ID, c_bpartner_created, C_BPartner_CreatedBy, C_BPartner_C_TaxGroup_ID, c_bpartner_deliveryrule, c_bpartner_deliveryviarule, c_bpartner_description, c_bpartner_dunninggrace, c_bpartner_firstsale, c_bpartner_flatdiscount, c_bpartner_freightcostrule, c_bpartner_invoicerule, c_bpartner_isactive, c_bpartner_iscustomer, c_bpartner_isdiscountprinted, c_bpartner_isemployee, c_bpartner_ismanufacturer, c_bpartner_isonetime, c_bpartner_ispotaxexempt, c_bpartner_isprospect, c_bpartner_issalesrep, c_bpartner_issummary, c_bpartner_istaxexempt, c_bpartner_isvendor, C_BPartner_Logo_ID, C_BPartner_M_DiscountSchema_ID, C_BPartner_M_PriceList_ID, c_bpartner_naics, c_bpartner_numberemployees, c_bpartner_paymentrule, c_bpartner_paymentrulepo, C_BPartnerPO_DiscountSchema_ID, C_BPartner_PO_PaymentTerm_ID, C_BPartner_PO_PriceList_ID, c_bpartner_poreference, c_bpartner_potentiallifetimev, c_bpartner_rating, C_BPartner_SalesRep_ID, c_bpartner_salesvolume, c_bpartner_sendemail, c_bpartner_shareofcustomer, c_bpartner_shelflifeminpct, c_bpartner_so_creditlimit, c_bpartner_socreditstatus, c_bpartner_so_creditused, c_bpartner_so_description, c_bpartner_totalopenbalance, c_bpartner_updated, C_BPartner_UpdatedBy, c_bpartner_url, C_BPartner_Greeting_AD_Org_ID, c_bpartner_greeting_isactive, c_bpartner_greeting_isfirstna, c_bpartner_greeting_name, C_BPartner_Location_AD_Org_ID, c_bpartner_location_created, C_BPartner_Location_CreatedBy, C_SalesRegion_ID, c_bpartner_location_fax, c_bpartner_location_isactive, IsBillTo, ISDN, IsPayFrom, IsRemitTo, IsShipTo, c_bpartner_location_name, c_bpartner_location_phone, c_bpartner_location_phone2, c_bpartner_location_updated, C_BPartner_Location_UpdatedBy, Address1, Address2, Address3, Address4, C_Location_AD_Org_ID, C_City_ID, C_Country_ID, City, c_location_created, C_Location_CreatedBy, C_Region_ID, c_location_isactive, Postal_Add, RegionName, c_location_updated, C_Location_UpdatedBy, AD_User_AD_Org_ID, AD_User_AD_AD_OrgTrx_ID, ad_user_ad_birthday, AD_User_C_BPartner_ID, AD_User_C_BPartner_Location_ID, AD_User_C_Greeting_ID, ad_user_comments, ad_user_created, AD_User_CreatedBy, ad_user_description, ad_user_email, ad_user_fax, ad_user_isactive, ad_user_lastcontact, ad_user_lastresult, ad_user_name, ad_user_phone2, AD_User_Supervisor_ID, ad_user_updated, AD_User_UpdatedBy, ad_user_value, C_User_Greeting_AD_Org_ID, c_user_greeting_isactive, c_user_greeting_isfirstnameon, c_user_greeting_name, AD_OrgInfo_AD_Org_ID, AD_OrgType_ID, C_Calendar_ID, ad_orginfo_created, AD_OrgInfo_CreatedBy, DropShip_Warehouse_ID, ad_orginfo_duns, ad_orginfo_email, ad_orginfo_fax, ad_orginfo_isactive, M_Warehouse_ID, Parent_Org
;
-- Nov 28, 2021, 11:19:14 PM CET
CREATE OR REPLACE VIEW RV_Payment(C_Payment_ID, AD_Client_ID, AD_Org_ID, IsActive, Created, CreatedBy, Updated, UpdatedBy, DocumentNo, DateTrx, IsReceipt, C_DocType_ID, TrxType, C_BankAccount_ID, C_BPartner_ID, C_Invoice_ID, C_BP_BankAccount_ID, C_PaymentBatch_ID, TenderType, CreditCardType, CreditCardNumber, CreditCardVV, CreditCardExpMM, CreditCardExpYY, Micr, RoutingNo, AccountNo, CheckNo, A_Name, A_Street, A_City, A_State, A_Zip, A_Ident_DL, A_Ident_SSN, A_EMail, VoiceAuthCode, Orig_TrxID, PONum, C_Currency_ID, C_ConversionType_ID, PayAmt, DiscountAmt, WriteOffAmt, TaxAmt, OverUnderAmt, MultiplierAP, AllocatedAmt, AvailableAmt, IsOverUnderPayment, IsApproved, R_PnRef, R_Result, R_RespMsg, R_AuthCode, R_AvsAddr, R_AvsZip, R_Info, Processing, OProcessing, DocStatus, DocAction, IsPrepayment, C_Charge_ID, IsReconciled, IsAllocated, IsOnline, Processed, Posted, C_Campaign_ID, C_Project_ID, C_Activity_ID, A_Country, AD_OrgTrx_ID, ChargeAmt, C_Order_ID, DateAcct, Description, IsDelayedCapture, IsSelfService, ProcessedOn, R_AuthCode_DC, R_CVV2Match, Ref_Payment_ID, Reversal_ID, R_PnRef_DC, Swipe, User1_ID, User2_ID) AS SELECT c_payment.c_payment_id AS C_Payment_ID, c_payment.ad_client_id AS AD_Client_ID, c_payment.ad_org_id AS AD_Org_ID, c_payment.isactive AS IsActive, c_payment.created AS Created, c_payment.createdby AS CreatedBy, c_payment.updated AS Updated, c_payment.updatedby AS UpdatedBy, c_payment.documentno AS DocumentNo, c_payment.datetrx AS DateTrx, c_payment.isreceipt AS IsReceipt, c_payment.c_doctype_id AS C_DocType_ID, c_payment.trxtype AS TrxType, c_payment.c_bankaccount_id AS C_BankAccount_ID, c_payment.c_bpartner_id AS C_BPartner_ID, c_payment.c_invoice_id AS C_Invoice_ID, c_payment.c_bp_bankaccount_id AS C_BP_BankAccount_ID, c_payment.c_paymentbatch_id AS C_PaymentBatch_ID, c_payment.tendertype AS TenderType, c_payment.creditcardtype AS CreditCardType, c_payment.creditcardnumber AS CreditCardNumber, c_payment.creditcardvv AS CreditCardVV, c_payment.creditcardexpmm AS CreditCardExpMM, c_payment.creditcardexpyy AS CreditCardExpYY, c_payment.micr AS Micr, c_payment.routingno AS RoutingNo, c_payment.accountno AS AccountNo, c_payment.checkno AS CheckNo, c_payment.a_name AS A_Name, c_payment.a_street AS A_Street, c_payment.a_city AS A_City, c_payment.a_state AS A_State, c_payment.a_zip AS A_Zip, c_payment.a_ident_dl AS A_Ident_DL, c_payment.a_ident_ssn AS A_Ident_SSN, c_payment.a_email AS A_EMail, c_payment.voiceauthcode AS VoiceAuthCode, c_payment.orig_trxid AS Orig_TrxID, c_payment.ponum AS PONum, c_payment.c_currency_id AS C_Currency_ID, c_payment.c_conversiontype_id AS C_ConversionType_ID, CASE c_payment.isreceipt WHEN 'Y' THEN c_payment.payamt ELSE c_payment.payamt * '-1' END AS PayAmt, CASE c_payment.isreceipt WHEN 'Y' THEN c_payment.discountamt ELSE c_payment.discountamt * '-1' END AS DiscountAmt, CASE c_payment.isreceipt WHEN 'Y' THEN c_payment.writeoffamt ELSE c_payment.writeoffamt * '-1' END AS WriteOffAmt, CASE c_payment.isreceipt WHEN 'Y' THEN c_payment.taxamt ELSE c_payment.taxamt * '-1' END AS TaxAmt, CASE c_payment.isreceipt WHEN 'Y' THEN c_payment.overunderamt ELSE c_payment.overunderamt * '-1' END AS OverUnderAmt, CASE c_payment.isreceipt WHEN 'Y' THEN 1 ELSE -1 END AS MultiplierAP, paymentallocated(c_payment.c_payment_id, c_payment.c_currency_id) AS AllocatedAmt, paymentavailable(c_payment.c_payment_id) AS AvailableAmt, c_payment.isoverunderpayment AS IsOverUnderPayment, c_payment.isapproved AS IsApproved, c_payment.r_pnref AS R_PnRef, c_payment.r_result AS R_Result, c_payment.r_respmsg AS R_RespMsg, c_payment.r_authcode AS R_AuthCode, c_payment.r_avsaddr AS R_AvsAddr, c_payment.r_avszip AS R_AvsZip, c_payment.r_info AS R_Info, c_payment.processing AS Processing, c_payment.oprocessing AS OProcessing, c_payment.docstatus AS DocStatus, c_payment.docaction AS DocAction, c_payment.isprepayment AS IsPrepayment, c_payment.c_charge_id AS C_Charge_ID, c_payment.isreconciled AS IsReconciled, c_payment.isallocated AS IsAllocated, c_payment.isonline AS IsOnline, c_payment.processed AS Processed, c_payment.
;
-- Nov 28, 2021, 11:19:14 PM CET
CREATE OR REPLACE VIEW RV_CommissionRunDetail(AD_Client_ID, AD_Org_ID, IsActive, Created, CreatedBy, Updated, UpdatedBy, C_CommissionRun_ID, DocumentNo, Description, StartDate, GrandTotal, Processed, C_Commission_ID, Commission_BPartner_ID, C_CommissionAmt_ID, CommissionConvertedAmt, CommissionQty, CommissionAmt, C_CommissionDetail_ID, Reference, C_OrderLine_ID, C_InvoiceLine_ID, Info, C_Currency_ID, ActualAmt, ConvertedAmt, ActualQty, InvoiceDocumentNo, DateDoc, M_Product_ID, C_BPartner_ID, C_BPartner_Location_ID, AD_User_ID, C_DocType_ID, c_commisionrun_processing, C_Commission_AD_Org_ID, C_Commission_C_Currency_ID, c_commission_created, C_Commission_CreatedBy, CreateFrom, DateLastRun, c_commission_description, DocBasisType, FrequencyType, c_commission_isactive, ListDetails, c_commission_name, c_commission_updated, C_Commission_UpdatedBy, C_CommissionAmt_AD_Org_ID, C_CommissionLine_ID, c_commmissionamt_created, C_CommmissionAmt_CreatedBy, c_commmissionamt_isactive, c_commmissionamt_updated, C_CommssionAmt_UpdatedBy, C_CommissionDetail_AD_Org_ID, c_commissiondetail_created, C_CommissionDetail_CreatedBy, c_commossiondetail_isactive, c_commissiondetail_updated, C_CommissionDetail_UpdatedBy, C_OrderLine_AD_Org_ID, C_OrderLine_AD_OrgTrx_ID, C_OrderLine_C_Activity_ID, C_OrderLine_C_BPartner_ID, C_OrderLine_C_BP_Location_ID, C_OrderLine_C_Campaign_ID, C_OrderLine_C_Charge_ID, C_OrderLine_C_Currency_ID, C_OrderLine_C_Order_ID, C_OrderLine_C_Project_ID, C_OrderLine_C_ProjectPhase_ID, C_OrderLine_C_ProjectTask_ID, c_orderline_created, C_OrderLine_CreatedBy, C_OrderLine_C_Tax_ID, C_OrderLine_C_UOM_ID, DateDelivered, DateInvoiced, DateOrdered, DatePromised, c_orderline_description, Discount, FreightAmt, c_orderline_isactive, IsDescription, c_orderline_line, c_orderline_linenetamt, Link_OrderLine_ID, C_OrderLine_M_ASI_ID, M_Promotion_ID, C_OrderLine_M_Shipper_ID, C_OrderLine_M_Warehouse_ID, c_orderline_priceactual, PriceCost, c_orderline_priceentered, c_orderline_pricelist, c_orderline_processed, QtyDelivered, QtyEntered, c_orderline_qtyinvoiced, QtyLostSales, QtyOrdered, QtyReserved, C_OrderLine_Ref_OrderLine_ID, c_orderline_rramt, c_orderline_rrstartsate, C_OrderLine_S_RAssignment_ID, c_orderline_updated, C_OrderLine_UpdatedBy, C_OrderLine_User1_ID, C_OrderLine_User2_ID, C_InviceLine_AD_Org_ID, C_InvoiceLine_AD_OrgTrx_ID, A_Processed, C_InvoiceLine_C_Activity_ID, C_InvoiceLine_C_Campaign_ID, C_InvoiceLine_C_Charge_ID, C_Invoice_ID, C_InvoiceLine_C_OrderLine_ID, C_InvoiceLine_C_Project_ID, C_InvoiceLine_C_ProjPhase_ID, C_InvoiceLine_C_ProjectTask_ID, c_invoiceline_created, C_InvoiceLine_CreatedBy, C_InvoiceLine_C_Tax_ID, C_InvoiceLine_C_UOM_ID, c_invoiceline_description, c_invoiceline_isactive, c_invoiceline_isdescription, IsPrinted, c_invoiceline_line, c_invoiceline_linenetamt, c_invoiceline_linetotalamt, C_InvoiceLine_M_ASI_ID, M_InOutLine_ID, C_InvoiceLine_M_RMALine_ID, c_invoiceline_priceactual, c_invoiceline_priceentered, c_invoiceline_pricelimit, c_invoiceline_pricelist, c_invoiceline_processed, c_invoiceline_qtyentered, c_invoiceline_qtyinvoiced, C_InvoiceLine_Ref_InvLine_ID, c_invoiceline_rramt, c_invoiceline_rrstartdate, C_InvoiceLine_S_RAssignment_ID, c_invoiceline_taxamt, c_invoiceline_updated, C_InvoiceLine_UpdatedBy, C_InvoiceLine_User1_ID, C_InvoiceLine_User2_ID, C_Order_AD_Org_ID, C_Order_AD_OrgTrx_ID, C_Order_AD_User_ID, AmountRefunded, AmountTendered, Bill_BPartner_ID, Bill_Location_ID, Bill_User_ID, C_Activity_ID, C_Order_C_Campaign_ID, C_CashLine_ID, C_CashPlanLine_ID, C_Charge_ID, C_ConversionType_ID, C_Order_C_Currency_ID, C_DocTypeTarget_ID, c_order_chargeamt, c_order_copyfrom, C_Order_C_Order_ID, C_Order_C_Payment_ID, C_Order_PaymentTerm_ID, C_POS_ID, C_Order_C_Project_ID, c_order_created, C_Order_CreatedBy, c_order_dateacct, c_order_dateprinted, c_order_datepromised, c_order_deliveryrule, c_order_deliveryviarule, c_order_description, c_order_docaction, c_order_docstatus, c_order_documentno, DropShip_BPartner_ID, DropShip_Location_ID, DropShip_User_ID, c_order_freightamt, c_order_freightcostrule, c_order_gr
;
-- Nov 28, 2021, 11:19:14 PM CET
CREATE OR REPLACE VIEW RV_Cost(AD_Client_ID, AD_Org_ID, IsActive, Created, CreatedBy, Updated, UpdatedBy, M_Product_ID, Value, Name, UPC, IsBOM, ProductType, M_Product_Category_ID, M_CostType_ID, M_CostElement_ID, CostElementType, CostingMethod, IsCalculated, C_AcctSchema_ID, C_Currency_ID, CurrentCostPrice, FutureCostPrice, Description, CurrentCostPriceLL, FutureCostPriceLL, IsCostFrozen, CumulatedAmt, CumulatedQty, CurrentQty, M_AttributeSetInstance_ID, Percent, M_Product_AD_Org_ID, Classification, m_product_copyfrom, m_product_created, M_Product_CreatedBy, C_RevenueRecognition_ID, C_SubscriptionType_ID, C_TaxCategory_ID, C_UOM_ID, m_product_description, DescriptionURL, Discontinued, DiscontinuedAt, DocumentNote, Group1, Group2, GuaranteeDays, GuaranteeDaysMin, Help, ImageURL, m_product_isactive, IsDropShip, IsExcludeAutoDelivery, IsInvoicePrintDetails, IsPickListPrintDetails, IsPurchased, IsSelfService, IsSold, IsStocked, m_product_issummary, IsVerified, IsWebStoreFeatured, LowLevel, M_Product_M_AttributeSet_ID, m_product_m_attributesetinsta, M_FreightCategory_ID, M_Locator_ID, m_product_processing, R_MailText_ID, M_Product_SalesRep_ID, S_ExpenseType_ID, ShelfDepth, ShelfHeight, ShelfWidth, SKU, S_Resource_ID, UnitsPerPack, UnitsPerPallet, m_product_updated, M_Product_UpdatedBy, VersionNo, Volume, Weight, M_CostElement_AD_Org_ID, m_costelement_description, m_costelement_isactive, m_costelement_name, C_AcctSchema_AD_Org_ID, c_acctschema_description, c_acctschema_name) AS SELECT c.ad_client_id AS AD_Client_ID, c.ad_org_id AS AD_Org_ID, c.isactive AS IsActive, c.created AS Created, c.createdby AS CreatedBy, c.updated AS Updated, c.updatedby AS UpdatedBy, p.m_product_id AS M_Product_ID, p.value AS Value, p.name AS Name, p.upc AS UPC, p.isbom AS IsBOM, p.producttype AS ProductType, p.m_product_category_id AS M_Product_Category_ID, c.m_costtype_id AS M_CostType_ID, ce.m_costelement_id AS M_CostElement_ID, ce.costelementtype AS CostElementType, ce.costingmethod AS CostingMethod, ce.iscalculated AS IsCalculated, acct.c_acctschema_id AS C_AcctSchema_ID, acct.c_currency_id AS C_Currency_ID, c.currentcostprice AS CurrentCostPrice, c.futurecostprice AS FutureCostPrice, c.description AS Description, c.currentcostpricell AS CurrentCostPriceLL, c.futurecostpricell AS FutureCostPriceLL, c.iscostfrozen AS IsCostFrozen, c.cumulatedamt AS CumulatedAmt, c.cumulatedqty AS CumulatedQty, c.currentqty AS CurrentQty, c.m_attributesetinstance_id AS M_AttributeSetInstance_ID, c.percent AS Percent, 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 C_UOM_ID, p.description AS m_product_description, p.descriptionurl AS DescriptionURL, p.discontinued AS Discontinued, p.discontinuedat AS DiscontinuedAt, p.documentnote AS DocumentNote, p.group1 AS Group1, p.group2 AS Group2, p.guaranteedays AS GuaranteeDays, p.guaranteedaysmin AS GuaranteeDaysMin, p.help AS Help, p.imageurl AS ImageURL, p.isactive AS m_product_isactive, p.isdropship AS IsDropShip, p.isexcludeautodelivery AS IsExcludeAutoDelivery, p.isinvoiceprintdetails AS IsInvoicePrintDetails, p.ispicklistprintdetails AS IsPickListPrintDetails, p.ispurchased AS IsPurchased, p.isselfservice AS 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_Product_M_AttributeSet_ID, p.m_attributesetinstance_id AS m_product_m_attributesetinsta, p.m_freightcategory_id AS M_FreightCategory_ID, p.m_locator_id AS M_Locator_ID, p.processing AS m_product_processing, 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.sku AS SKU, p.
;
-- Nov 28, 2021, 11:19:14 PM CET
CREATE OR REPLACE VIEW RV_C_InvoiceLine(AD_Client_ID, AD_Org_ID, IsActive, Created, CreatedBy, Updated, UpdatedBy, C_InvoiceLine_ID, C_Invoice_ID, SalesRep_ID, C_BPartner_ID, C_BP_Group_ID, M_Product_ID, M_Product_Category_ID, DateInvoiced, DateAcct, IsSOTrx, C_DocType_ID, DocStatus, IsPaid, C_Campaign_ID, C_Project_ID, C_Activity_ID, C_ProjectPhase_ID, C_ProjectTask_ID, QtyInvoiced, QtyEntered, M_AttributeSetInstance_ID, ProductAttribute, M_AttributeSet_ID, M_Lot_ID, GuaranteeDate, Lot, SerNo, PriceList, PriceActual, PriceLimit, PriceEntered, Discount, Margin, MarginAmt, LineNetAmt, LineListAmt, LineLimitAmt, LineDiscountAmt, LineOverLimitAmt, AD_OrgTrx_ID, A_Processed, C_Charge_ID, C_OrderLine_ID, C_Tax_ID, C_InvoiceLine_C_UOM_ID, c_invoiceline_description, IsDescription, IsPrinted, Line, c_invoiceline_linenetamt, LineTotalAmt, M_InOutLine_ID, M_RMALine_ID, Processed, Ref_InvoiceLine_ID, RRAmt, RRStartDate, S_ResourceAssignment_ID, TaxAmt, User1_ID, User2_ID, 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_ProductLine_C_UOM_ID, m_product_description, DescriptionURL, Discontinued, DiscontinuedAt, DocumentNote, Group1, Group2, GuaranteeDays, GuaranteeDaysMin, Help, ImageURL, m_product_isactive, IsDropShip, IsExcludeAutoDelivery, IsInvoicePrintDetails, IsPickListPrintDetails, IsPurchased, IsSelfService, IsSold, IsStocked, m_product_issummary, IsVerified, IsWebStoreFeatured, LowLevel, M_Product_M_AttributeSet_ID, M_FreightCategory_ID, M_Locator_ID, M_Product_M_Product_ID, m_product_processing, ProductType, R_MailText_ID, M_Product_SalesRep_ID, S_ExpenseType_ID, ShelfDepth, ShelfHeight, ShelfWidth, SKU, S_Resource_ID, UnitsPerPack, UnitsPerPallet, m_product_updated, M_Product_UpdatedBy, VersionNo, Volume, Weight, M_ASI_AD_Org_ID, m_attributesetinstance_created, M_ASI_CreatedBy, M_ASI_Description, m_attributesetinstance_isacti, m_attributesetinstance_serno, m_attributesetinstance_updated, M_ASI_UpdatedBy, M_Product_Category_Parent_ID) AS SELECT il.ad_client_id AS AD_Client_ID, il.ad_org_id AS AD_Org_ID, il.isactive AS IsActive, il.created AS Created, il.createdby AS CreatedBy, il.updated AS Updated, il.updatedby AS UpdatedBy, il.c_invoiceline_id AS C_InvoiceLine_ID, i.c_invoice_id AS C_Invoice_ID, i.salesrep_id AS SalesRep_ID, i.c_bpartner_id AS C_BPartner_ID, i.c_bp_group_id AS C_BP_Group_ID, il.m_product_id AS M_Product_ID, p.m_product_category_id AS M_Product_Category_ID, i.dateinvoiced AS DateInvoiced, i.dateacct AS DateAcct, i.issotrx AS IsSOTrx, i.c_doctype_id AS C_DocType_ID, i.docstatus AS DocStatus, i.ispaid AS IsPaid, il.c_campaign_id AS C_Campaign_ID, il.c_project_id AS C_Project_ID, il.c_activity_id AS C_Activity_ID, il.c_projectphase_id AS C_ProjectPhase_ID, il.c_projecttask_id AS C_ProjectTask_ID, il.qtyinvoiced * i.multiplier AS QtyInvoiced, il.qtyentered * i.multiplier AS QtyEntered, il.m_attributesetinstance_id AS M_AttributeSetInstance_ID, productattribute(il.m_attributesetinstance_id) AS ProductAttribute, pasi.m_attributeset_id AS M_AttributeSet_ID, pasi.m_lot_id AS M_Lot_ID, pasi.guaranteedate AS GuaranteeDate, pasi.lot AS Lot, pasi.serno AS SerNo, il.pricelist AS PriceList, il.priceactual AS PriceActual, il.pricelimit AS PriceLimit, il.priceentered AS PriceEntered, CASE WHEN il.pricelist = 0 THEN 0 ELSE currencyround((il.pricelist - il.priceactual) / il.pricelist * 100, i.c_currency_id, 'N') END AS Discount, CASE WHEN il.pricelimit = 0 THEN 0 ELSE currencyround((il.priceactual - il.pricelimit) / il.pricelimit * 100, i.c_currency_id, 'N') END AS Margin, CASE WHEN il.pricelimit = 0 THEN 0 ELSE (il.priceactual - il.pricelimit) * il.qtyinvoiced * i.multiplier END AS MarginAmt, currencyround(i.multiplier * il.linenetamt, i.c_currency_id, 'N') AS LineNetAmt, currencyround(i.multiplier * il.pricelist * il.qtyinvoiced, i.c_currency_id, 'N') AS LineListAmt, CASE WHEN COALESCE(il.pricelimit, 0) = 0 THEN currencyround(i.multiplier * il.linenetamt, i.c_currency_id, 'N') ELSE currencyround(i.multiplie
;
-- Nov 28, 2021, 11:19:14 PM CET
CREATE OR REPLACE VIEW RV_Asset_SumMonth(AD_Client_ID, AD_Org_ID, IsActive, Created, CreatedBy, Updated, UpdatedBy, A_Asset_ID, A_Asset_Group_ID, M_Product_ID, Value, Name, Description, Help, GuaranteeDate, AssetServiceDate, C_BPartner_ID, AD_User_ID, SerNo, Lot, VersionNo, MovementDate, DeliveryCount) AS SELECT a.ad_client_id AS AD_Client_ID, a.ad_org_id AS AD_Org_ID, a.isactive AS IsActive, a.created AS Created, a.createdby AS CreatedBy, a.updated AS Updated, a.updatedby AS UpdatedBy, a.a_asset_id AS A_Asset_ID, a.a_asset_group_id AS A_Asset_Group_ID, a.m_product_id AS M_Product_ID, a.value AS Value, a.name AS Name, a.description AS Description, a.help AS Help, a.guaranteedate AS GuaranteeDate, a.assetservicedate AS AssetServiceDate, a.c_bpartner_id AS C_BPartner_ID, a.ad_user_id AS AD_User_ID, a.serno AS SerNo, a.lot AS Lot, a.versionno AS VersionNo, firstof(ad.movementdate, 'MM') AS MovementDate, count(*) AS DeliveryCount FROM a_asset a JOIN a_asset_delivery ad ON a.a_asset_id = ad.a_asset_id GROUP BY a.ad_client_id, a.ad_org_id, a.isactive, a.created, a.createdby, a.updated, a.updatedby, a.a_asset_id, a.a_asset_group_id, a.m_product_id, a.value, a.name, a.description, a.help, a.guaranteedate, a.assetservicedate, a.c_bpartner_id, a.ad_user_id, a.serno, a.lot, a.versionno, (firstof(ad.movementdate, 'MM'))
;
-- Nov 28, 2021, 11:19:15 PM CET
CREATE OR REPLACE VIEW RV_RequestUpdates(AD_Client_ID, AD_Org_ID, IsActive, Created, CreatedBy, Updated, UpdatedBy, R_Request_ID, AD_User_ID, IsSelfService, R_Group_ID, R_RequestType_ID, R_Category_ID) AS SELECT r_requestupdates.ad_client_id AS AD_Client_ID, r_requestupdates.ad_org_id AS AD_Org_ID, r_requestupdates.isactive AS IsActive, r_requestupdates.created AS Created, r_requestupdates.createdby AS CreatedBy, r_requestupdates.updated AS Updated, r_requestupdates.updatedby AS UpdatedBy, r_requestupdates.r_request_id AS R_Request_ID, r_requestupdates.ad_user_id AS AD_User_ID, r_requestupdates.isselfservice AS IsSelfService, NULLIF(1,1) AS R_Group_ID, NULLIF(1,1) AS R_RequestType_ID, NULLIF(1,1) AS R_Category_ID FROM r_requestupdates UNION SELECT u.ad_client_id AS AD_Client_ID, u.ad_org_id AS AD_Org_ID, u.isactive AS IsActive, u.created AS Created, u.createdby AS CreatedBy, u.updated AS Updated, u.updatedby AS UpdatedBy, r.r_request_id AS R_Request_ID, u.ad_user_id AS AD_User_ID, u.isselfservice AS IsSelfService, r.r_group_id AS R_Group_ID, NULL AS R_RequestType_ID, NULL AS R_Category_ID FROM r_groupupdates u JOIN r_request r ON u.r_group_id = r.r_group_id UNION SELECT u.ad_client_id AS AD_Client_ID, u.ad_org_id AS AD_Org_ID, u.isactive AS IsActive, u.created AS Created, u.createdby AS CreatedBy, u.updated AS Updated, u.updatedby AS UpdatedBy, r.r_request_id AS R_Request_ID, u.ad_user_id AS AD_User_ID, u.isselfservice AS IsSelfService, NULL AS R_Group_ID, r.r_requesttype_id AS R_RequestType_ID, NULL AS R_Category_ID FROM r_requesttypeupdates u JOIN r_request r ON u.r_requesttype_id = r.r_requesttype_id UNION SELECT u.ad_client_id AS AD_Client_ID, u.ad_org_id AS AD_Org_ID, u.isactive AS IsActive, u.created AS Created, u.createdby AS CreatedBy, u.updated AS Updated, u.updatedby AS UpdatedBy, r.r_request_id AS R_Request_ID, u.ad_user_id AS AD_User_ID, u.isselfservice AS IsSelfService, NULL AS R_Group_ID, NULL AS R_RequestType_ID, r.r_category_id AS R_Category_ID FROM r_categoryupdates u JOIN r_request r ON u.r_category_id = r.r_category_id UNION SELECT r_request.ad_client_id AS AD_Client_ID, r_request.ad_org_id AS AD_Org_ID, r_request.isactive AS IsActive, r_request.created AS Created, r_request.createdby AS CreatedBy, r_request.updated AS Updated, r_request.updatedby AS UpdatedBy, r_request.r_request_id AS R_Request_ID, r_request.ad_user_id AS AD_User_ID, r_request.isselfservice AS IsSelfService, NULL AS R_Group_ID, NULL AS R_RequestType_ID, NULL AS R_Category_ID FROM r_request WHERE r_request.ad_user_id IS NOT NULL UNION SELECT u.ad_client_id AS AD_Client_ID, u.ad_org_id AS AD_Org_ID, u.isactive AS IsActive, u.created AS Created, u.createdby AS CreatedBy, u.updated AS Updated, u.updatedby AS UpdatedBy, r.r_request_id AS R_Request_ID, u.ad_user_id AS AD_User_ID, NULL AS IsSelfService, NULL AS R_Group_ID, NULL AS R_RequestType_ID, r.r_category_id AS R_Category_ID FROM ad_user u JOIN r_request r ON u.ad_user_id = r.salesrep_id UNION SELECT r.ad_client_id AS AD_Client_ID, r.ad_org_id AS AD_Org_ID, u.isactive AS IsActive, r.created AS Created, r.createdby AS CreatedBy, r.updated AS Updated, r.updatedby AS UpdatedBy, r.r_request_id AS R_Request_ID, u.ad_user_id AS AD_User_ID, NULL AS IsSelfService, NULL AS R_Group_ID, NULL AS R_RequestType_ID, NULL AS R_Category_ID FROM r_request r JOIN ad_user_roles u ON u.ad_role_id = r.ad_role_id
;
-- Nov 28, 2021, 11:19:15 PM CET
CREATE OR REPLACE VIEW RV_C_Invoice_Day(AD_Client_ID, AD_Org_ID, SalesRep_ID, DateInvoiced, LineNetAmt, LineListAmt, LineLimitAmt, LineDiscountAmt, LineDiscount, LineOverLimitAmt, LineOverLimit, IsSOTrx) AS SELECT il.ad_client_id AS AD_Client_ID, il.ad_org_id AS AD_Org_ID, il.salesrep_id AS SalesRep_ID, firstof(il.dateinvoiced, 'DD') AS DateInvoiced, sum(il.linenetamt) AS LineNetAmt, sum(il.linelistamt) AS LineListAmt, sum(il.linelimitamt) AS LineLimitAmt, sum(il.linediscountamt) AS LineDiscountAmt, CASE WHEN sum(il.linelistamt) = 0 THEN 0 ELSE currencyround((sum(il.linelistamt) - sum(il.linenetamt)) / sum(il.linelistamt) * 100, i.c_currency_id, 'N') END AS LineDiscount, sum(il.lineoverlimitamt) AS LineOverLimitAmt, CASE WHEN sum(il.linenetamt) = 0 THEN 0 ELSE 100 - currencyround((sum(il.linenetamt) - sum(il.lineoverlimitamt)) / sum(il.linenetamt) * 100, i.c_currency_id, 'N') END AS LineOverLimit, il.issotrx AS IsSOTrx FROM rv_c_invoiceline il JOIN c_invoice i ON i.c_invoice_id = il.c_invoice_id GROUP BY il.ad_client_id, il.ad_org_id, il.salesrep_id, (firstof(il.dateinvoiced, 'DD')), il.issotrx, i.c_currency_id
;
-- Nov 28, 2021, 11:19:15 PM CET
CREATE OR REPLACE VIEW RV_C_Invoice_Month(AD_Client_ID, AD_Org_ID, SalesRep_ID, DateInvoiced, LineNetAmt, LineListAmt, LineLimitAmt, LineDiscountAmt, LineDiscount, LineOverLimitAmt, LineOverLimit, IsSOTrx) AS SELECT il.ad_client_id AS AD_Client_ID, il.ad_org_id AS AD_Org_ID, il.salesrep_id AS SalesRep_ID, firstof(il.dateinvoiced, 'MM') AS DateInvoiced, sum(il.linenetamt) AS LineNetAmt, sum(il.linelistamt) AS LineListAmt, sum(il.linelimitamt) AS LineLimitAmt, sum(il.linediscountamt) AS LineDiscountAmt, CASE WHEN sum(il.linelistamt) = 0 THEN 0 ELSE currencyround((sum(il.linelistamt) - sum(il.linenetamt)) / sum(il.linelistamt) * 100, i.c_currency_id, 'N') END AS LineDiscount, sum(il.lineoverlimitamt) AS LineOverLimitAmt, CASE WHEN sum(il.linenetamt) = 0 THEN 0 ELSE 100 - currencyround((sum(il.linenetamt) - sum(il.lineoverlimitamt)) / sum(il.linenetamt) * 100, i.c_currency_id, 'N') END AS LineOverLimit, il.issotrx AS IsSOTrx FROM rv_c_invoiceline il JOIN c_invoice i ON i.c_invoice_id = il.c_invoice_id GROUP BY il.ad_client_id, il.ad_org_id, il.salesrep_id, (firstof(il.dateinvoiced, 'MM')), il.issotrx, i.c_currency_id
;
-- Nov 28, 2021, 11:19:15 PM CET
CREATE OR REPLACE VIEW RV_C_Invoice_ProdWeek(AD_Client_ID, AD_Org_ID, M_Product_Category_ID, DateInvoiced, LineNetAmt, LineListAmt, LineLimitAmt, LineDiscountAmt, LineDiscount, LineOverLimitAmt, LineOverLimit, QtyInvoiced, IsSOTrx) AS SELECT il.ad_client_id AS AD_Client_ID, il.ad_org_id AS AD_Org_ID, il.m_product_category_id AS M_Product_Category_ID, firstof(il.dateinvoiced, 'DY') AS DateInvoiced, sum(il.linenetamt) AS LineNetAmt, sum(il.linelistamt) AS LineListAmt, sum(il.linelimitamt) AS LineLimitAmt, sum(il.linediscountamt) AS LineDiscountAmt, CASE WHEN sum(il.linelistamt) = 0 THEN 0 ELSE currencyround((sum(il.linelistamt) - sum(il.linenetamt)) / sum(il.linelistamt) * 100, i.c_currency_id, 'N') END AS LineDiscount, sum(il.lineoverlimitamt) AS LineOverLimitAmt, CASE WHEN sum(il.linenetamt) = 0 THEN 0 ELSE 100 - currencyround((sum(il.linenetamt) - sum(il.lineoverlimitamt)) / sum(il.linenetamt) * 100, i.c_currency_id, 'N') END AS LineOverLimit, sum(il.qtyinvoiced) AS QtyInvoiced, il.issotrx AS IsSOTrx FROM rv_c_invoiceline il JOIN c_invoice i ON i.c_invoice_id = il.c_invoice_id GROUP BY il.ad_client_id, il.ad_org_id, il.m_product_category_id, (firstof(il.dateinvoiced, 'DY')), il.issotrx, i.c_currency_id
;
-- Nov 28, 2021, 11:19:15 PM CET
CREATE OR REPLACE VIEW RV_C_Invoice_VendorMonth(AD_Client_ID, AD_Org_ID, C_BPartner_ID, M_Product_Category_ID, DateInvoiced, LineNetAmt, LineListAmt, LineLimitAmt, LineDiscountAmt, LineDiscount, LineOverLimitAmt, LineOverLimit, QtyInvoiced) AS SELECT il.ad_client_id AS AD_Client_ID, il.ad_org_id AS AD_Org_ID, po.c_bpartner_id AS C_BPartner_ID, il.m_product_category_id AS M_Product_Category_ID, firstof(il.dateinvoiced, 'MM') AS DateInvoiced, sum(il.linenetamt) AS LineNetAmt, sum(il.linelistamt) AS LineListAmt, sum(il.linelimitamt) AS LineLimitAmt, sum(il.linediscountamt) AS LineDiscountAmt, CASE WHEN sum(il.linelistamt) = 0 THEN 0 ELSE currencyround((sum(il.linelistamt) - sum(il.linenetamt)) / sum(il.linelistamt) * 100, i.c_currency_id, 'N') END AS LineDiscount, sum(il.lineoverlimitamt) AS LineOverLimitAmt, CASE WHEN sum(il.linenetamt) = 0 THEN 0 ELSE 100 - currencyround((sum(il.linenetamt) - sum(il.lineoverlimitamt)) / sum(il.linenetamt) * 100, i.c_currency_id, 'N') END AS LineOverLimit, sum(il.qtyinvoiced) AS QtyInvoiced FROM rv_c_invoiceline il JOIN c_invoice i ON i.c_invoice_id = il.c_invoice_id JOIN m_product_po po ON il.m_product_id = po.m_product_id WHERE il.issotrx = 'Y' GROUP BY il.ad_client_id, il.ad_org_id, po.c_bpartner_id, il.m_product_category_id, (firstof(il.dateinvoiced, 'MM')), i.c_currency_id
;
-- Nov 28, 2021, 11:19:15 PM CET
CREATE OR REPLACE VIEW RV_C_Invoice_Week(AD_Client_ID, AD_Org_ID, SalesRep_ID, DateInvoiced, LineNetAmt, LineListAmt, LineLimitAmt, LineDiscountAmt, LineDiscount, LineOverLimitAmt, LineOverLimit, IsSOTrx) AS SELECT il.ad_client_id AS AD_Client_ID, il.ad_org_id AS AD_Org_ID, il.salesrep_id AS SalesRep_ID, firstof(il.dateinvoiced, 'DY') AS DateInvoiced, sum(il.linenetamt) AS LineNetAmt, sum(il.linelistamt) AS LineListAmt, sum(il.linelimitamt) AS LineLimitAmt, sum(il.linediscountamt) AS LineDiscountAmt, CASE WHEN sum(il.linelistamt) = 0 THEN 0 ELSE currencyround((sum(il.linelistamt) - sum(il.linenetamt)) / sum(il.linelistamt) * 100, i.c_currency_id, 'N') END AS LineDiscount, sum(il.lineoverlimitamt) AS LineOverLimitAmt, CASE WHEN sum(il.linenetamt) = 0 THEN 0 ELSE 100 - currencyround((sum(il.linenetamt) - sum(il.lineoverlimitamt)) / sum(il.linenetamt) * 100, i.c_currency_id, 'N') END AS LineOverLimit, il.issotrx AS IsSOTrx FROM rv_c_invoiceline il JOIN c_invoice i ON i.c_invoice_id = il.c_invoice_id GROUP BY il.ad_client_id, il.ad_org_id, il.salesrep_id, (firstof(il.dateinvoiced, 'DY')), il.issotrx, i.c_currency_id
;
-- Nov 28, 2021, 11:19:15 PM CET
CREATE OR REPLACE VIEW RV_C_Invoice_CustomerProdQtr(AD_Client_ID, AD_Org_ID, C_BPartner_ID, M_Product_Category_ID, DateInvoiced, LineNetAmt, LineListAmt, LineLimitAmt, LineDiscountAmt, LineDiscount, LineOverLimitAmt, LineOverLimit, QtyInvoiced, IsSOTrx) AS SELECT il.ad_client_id AS AD_Client_ID, il.ad_org_id AS AD_Org_ID, il.c_bpartner_id AS C_BPartner_ID, il.m_product_category_id AS M_Product_Category_ID, firstof(il.dateinvoiced, 'Q') AS DateInvoiced, sum(il.linenetamt) AS LineNetAmt, sum(il.linelistamt) AS LineListAmt, sum(il.linelimitamt) AS LineLimitAmt, sum(il.linediscountamt) AS LineDiscountAmt, CASE WHEN sum(il.linelistamt) = 0 THEN 0 ELSE currencyround((sum(il.linelistamt) - sum(il.linenetamt)) / sum(il.linelistamt) * 100, i.c_currency_id, 'N') END AS LineDiscount, sum(il.lineoverlimitamt) AS LineOverLimitAmt, CASE WHEN sum(il.linenetamt) = 0 THEN 0 ELSE 100 - currencyround((sum(il.linenetamt) - sum(il.lineoverlimitamt)) / sum(il.linenetamt) * 100, i.c_currency_id, 'N') END AS LineOverLimit, sum(il.qtyinvoiced) AS QtyInvoiced, il.issotrx AS IsSOTrx FROM rv_c_invoiceline il JOIN c_invoice i ON i.c_invoice_id = il.c_invoice_id GROUP BY il.ad_client_id, il.ad_org_id, il.c_bpartner_id, il.m_product_category_id, (firstof(il.dateinvoiced, 'Q')), il.issotrx, i.c_currency_id
;
-- Nov 28, 2021, 11:19:15 PM CET
CREATE OR REPLACE VIEW RV_C_Invoice_CustomerVendQtr(AD_Client_ID, AD_Org_ID, C_BPartner_ID, Vendor_ID, DateInvoiced, LineNetAmt, LineListAmt, LineLimitAmt, LineDiscountAmt, LineDiscount, LineOverLimitAmt, LineOverLimit, QtyInvoiced) AS SELECT il.ad_client_id AS AD_Client_ID, il.ad_org_id AS AD_Org_ID, il.c_bpartner_id AS C_BPartner_ID, po.c_bpartner_id AS Vendor_ID, firstof(il.dateinvoiced, 'Q') AS DateInvoiced, sum(il.linenetamt) AS LineNetAmt, sum(il.linelistamt) AS LineListAmt, sum(il.linelimitamt) AS LineLimitAmt, sum(il.linediscountamt) AS LineDiscountAmt, CASE WHEN sum(il.linelistamt) = 0 THEN 0 ELSE currencyround((sum(il.linelistamt) - sum(il.linenetamt)) / sum(il.linelistamt) * 100, i.c_currency_id, 'N') END AS LineDiscount, sum(il.lineoverlimitamt) AS LineOverLimitAmt, CASE WHEN sum(il.linenetamt) = 0 THEN 0 ELSE 100 - currencyround((sum(il.linenetamt) - sum(il.lineoverlimitamt)) / sum(il.linenetamt) * 100, i.c_currency_id, 'N') END AS LineOverLimit, sum(il.qtyinvoiced) AS QtyInvoiced FROM rv_c_invoiceline il JOIN c_invoice i ON i.c_invoice_id = il.c_invoice_id JOIN m_product_po po ON il.m_product_id = po.m_product_id WHERE il.issotrx = 'Y' GROUP BY il.ad_client_id, il.ad_org_id, il.c_bpartner_id, po.c_bpartner_id, (firstof(il.dateinvoiced, 'Q')), i.c_currency_id
;
-- Nov 28, 2021, 11:19:15 PM CET
CREATE OR REPLACE VIEW RV_C_Invoice(C_Invoice_ID, AD_Client_ID, AD_Org_ID, IsActive, Created, CreatedBy, Updated, UpdatedBy, IsSOTrx, DocumentNo, DocStatus, DocAction, IsPrinted, IsDiscountPrinted, Processing, Processed, IsTransferred, IsPaid, C_DocType_ID, C_DocTypeTarget_ID, C_Order_ID, Description, IsApproved, SalesRep_ID, DateInvoiced, DatePrinted, DateAcct, C_BPartner_ID, C_BPartner_Location_ID, AD_User_ID, C_BP_Group_ID, POReference, DateOrdered, C_Currency_ID, C_ConversionType_ID, PaymentRule, C_PaymentTerm_ID, M_PriceList_ID, C_Campaign_ID, C_Project_ID, C_Activity_ID, IsPayScheduleValid, InvoiceCollectionType, C_Country_ID, C_Region_ID, Postal, City, C_Charge_ID, ChargeAmt, TotalLines, GrandTotal, Multiplier, C_Invoice_AD_OrgTrx_ID, C_Invoice_C_ConversionType_ID, C_DunningLevel_ID, C_Payment_ID, c_invoice_dateordered, DunningGrace, GenerateTo, IsInDispute, c_invoice_ispayschedulevalid, c_invoice_isselfservice, IsTaxIncluded, M_RMA_ID, Posted, ProcessedOn, Ref_Invoice_ID, Reversal_ID, SendEMail, User1_ID, User2_ID, c_bp_acqusitioncost, c_bp_actuallifetimevalue, c_bp_ad_language, C_BP_AD_OrgBP_ID, C_BP_AD_Org_ID, C_BP_BPartner_Parent_ID, C_BP_C_Dunning_ID, C_BP_C_Greeting_ID, C_BP_C_InvoiceSchedule_ID, C_BP_C_PaymentTerm_ID, c_bp_created, C_BP_CreatedBy, C_BP_C_TaxGroup_ID, c_bp_deliveryrule, c_bp_deliveryviarule, c_bp_description, c_bp_dunninggrace, c_bp_duns, c_bp_firstsale, c_bp_flatdiscount, c_bp_freightcostrule, c_bp_invoicerule, c_bp_isactive, c_bp_iscustomer, c_bp_isdiscountprinted, c_bp_isemployee, c_bp_ismanufacturer, c_bp_isonetime, c_bp_ispotaxexempt, c_bp_isprospect, c_bp_issalesrep, c_bp_issummary, c_bp_istaxexempt, c_bp_isvendor, C_BP_Logo_ID, C_BP_M_DiscountSchema_ID, C_BP_M_PriceList_ID, c_bp_naics, c_bp_name, c_bp_name2, c_bp_numberemployees, c_bp_paymentrule, c_bp_paymentrulepo, C_BP_PO_DiscountSchema_ID, C_BP_PO_PaymentTerm_ID, C_BP_PO_PriceList_ID, c_bp_poreference, c_bp_potentiallifetimevalue, c_bp_rating, c_bp_referenceno, C_BP_SalesRep_ID, c_bp_salesvolume, c_bp_sendemail, c_bp_shareofcustomer, c_bp_shelflifeminpct, c_bp_so_creditlimit, c_bp_socreditstatus, c_bp_so_creditused, c_bp_so_description, TaxID, c_bp_totalopenbalance, c_bp_updated, C_BP_UpdatedBy, c_bp_url, c_bp_value, C_BP_Location_AD_Org_ID, C_BP_Location_C_BPartner_ID, C_BP_Location_C_Location_ID, c_bp_location_created, C_BP_Location_CreatedBy, C_SalesRegion_ID, c_bp_location_fax, c_bp_location_isactive, IsBillTo, ISDN, IsPayFrom, IsRemitTo, IsShipTo, c_bp_location_name, c_bp_location_phone, c_bp_location_phone2, c_bp_location_updated, C_BP_Location_UpdatedBy, Address1, Address2, Address3, Address4, C_Location_AD_Org_ID, C_City_ID, c_location_created, C_Location_CreatedBy, c_location_isactive, Postal_Add, RegionName, c_location_updated, C_Location_UpdatedBy) AS SELECT i.c_invoice_id AS C_Invoice_ID, 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, i.issotrx AS IsSOTrx, i.documentno AS DocumentNo, i.docstatus AS DocStatus, i.docaction AS DocAction, i.isprinted AS IsPrinted, i.isdiscountprinted AS IsDiscountPrinted, i.processing AS Processing, i.processed AS Processed, i.istransferred AS IsTransferred, i.ispaid AS IsPaid, i.c_doctype_id AS C_DocType_ID, i.c_doctypetarget_id AS C_DocTypeTarget_ID, i.c_order_id AS C_Order_ID, i.description AS Description, i.isapproved AS IsApproved, i.salesrep_id AS SalesRep_ID, i.dateinvoiced AS DateInvoiced, i.dateprinted AS DatePrinted, i.dateacct AS DateAcct, i.c_bpartner_id AS C_BPartner_ID, i.c_bpartner_location_id AS C_BPartner_Location_ID, i.ad_user_id AS AD_User_ID, b.c_bp_group_id AS C_BP_Group_ID, i.poreference AS POReference, i.dateordered AS DateOrdered, i.c_currency_id AS C_Currency_ID, i.c_conversiontype_id AS C_ConversionType_ID, i.paymentrule AS PaymentRule, i.c_paymentterm_id AS C_PaymentTerm_ID, i.m_pricelist_id AS M_PriceList_ID, i.c_campaign_id AS C_Campaign_ID, i.c_project_id AS C_Project_ID, i.c_activity_id AS C_Activity_ID, i.ispayschedulevalid AS I
;
-- Nov 28, 2021, 11:19:15 PM CET
CREATE OR REPLACE VIEW RV_InOutLineConfirm(M_InOutConfirm_ID, M_InOutLineConfirm_ID, AD_Client_ID, AD_Org_ID, IsActive, Created, CreatedBy, Updated, UpdatedBy, TargetQty, ConfirmedQty, DifferenceQty, ScrappedQty, Description, Processed, M_InOut_ID, DocumentNo, ConfirmType, IsApproved, IsCancelled, C_BPartner_ID, C_BPartner_Location_ID, M_Warehouse_ID, C_Order_ID, IsSOTrx, M_InOutLine_ID, M_Product_ID, M_AttributeSetInstance_ID, M_Locator_ID) AS SELECT cl.m_inoutconfirm_id AS M_InOutConfirm_ID, cl.m_inoutlineconfirm_id AS M_InOutLineConfirm_ID, cl.ad_client_id AS AD_Client_ID, cl.ad_org_id AS AD_Org_ID, cl.isactive AS IsActive, cl.created AS Created, cl.createdby AS CreatedBy, cl.updated AS Updated, cl.updatedby AS UpdatedBy, cl.targetqty AS TargetQty, cl.confirmedqty AS ConfirmedQty, cl.differenceqty AS DifferenceQty, cl.scrappedqty AS ScrappedQty, cl.description AS Description, cl.processed AS Processed, c.m_inout_id AS M_InOut_ID, c.documentno AS DocumentNo, c.confirmtype AS ConfirmType, c.isapproved AS IsApproved, c.iscancelled AS IsCancelled, i.c_bpartner_id AS C_BPartner_ID, i.c_bpartner_location_id AS C_BPartner_Location_ID, i.m_warehouse_id AS M_Warehouse_ID, i.c_order_id AS C_Order_ID, i.issotrx AS IsSOTrx, cl.m_inoutline_id AS M_InOutLine_ID, il.m_product_id AS M_Product_ID, il.m_attributesetinstance_id AS M_AttributeSetInstance_ID, il.m_locator_id AS M_Locator_ID FROM m_inoutlineconfirm cl JOIN m_inoutconfirm c ON cl.m_inoutconfirm_id = c.m_inoutconfirm_id JOIN m_inout i ON c.m_inout_id = i.m_inout_id JOIN m_inoutline il ON cl.m_inoutline_id = il.m_inoutline_id
;
-- Nov 28, 2021, 11:19:15 PM CET
CREATE OR REPLACE VIEW T_InvoiceGL_v(AD_Client_ID, AD_Org_ID, IsActive, Created, CreatedBy, Updated, UpdatedBy, C_Invoice_ID, IsSOTrx, DocumentNo, DocStatus, C_DocType_ID, C_Order_ID, Description, SalesRep_ID, DateInvoiced, DateAcct, C_PaymentTerm_ID, C_BPartner_ID, C_BPartner_Location_ID, AD_User_ID, IsSelfService, C_Currency_ID, C_ConversionType_ID, GrandTotal, IsTaxIncluded, C_Campaign_ID, C_Project_ID, C_Activity_ID, AD_OrgTrx_ID, User1_ID, User2_ID, C_LocFrom_ID, C_LocTo_ID, C_SalesRegion_ID, Fact_Acct_ID, C_AcctSchema_ID, Account_ID, C_Period_ID, GL_Category_ID, GL_Budget_ID, C_Tax_ID, M_Locator_ID, PostingType, AmtSourceDr, AmtSourceCr, AmtAcctDr, AmtAcctCr, C_UOM_ID, Qty, AD_PInstance_ID, APAR, OpenAmt, Percent, AmtRevalDr, AmtRevalCr, DateReval, C_ConversionTypeReval_ID, AmtSourceBalance, AmtAcctBalance, C_DocTypeReval_ID, AmtRevalDrDiff, AmtRevalCrDiff, IsAllCurrencies, AmtAcctOpenDr, AmtAcctOpenCr, AmtAcctOpenBalance, T_InvoiceGL_AD_Org_ID, T_InvoiceGL_C_Invoice_ID, t_invoicegl_created, T_InvoiceGL_CreatedBy, t_invoicegl_grandtotal, t_invoicegl_isactive, t_invoicegl_updated, T_InvoiceGL_UpdatedBy, C_Invoice_C_Charge_ID, C_DocTypeTarget_ID, C_DunningLevel_ID, ChargeAmt, C_Payment_ID, DateOrdered, DatePrinted, DocAction, DunningGrace, GenerateTo, InvoiceCollectionType, IsApproved, IsDiscountPrinted, IsInDispute, IsPaid, IsPayScheduleValid, IsPrinted, IsTransferred, M_PriceList_ID, M_RMA_ID, PaymentRule, POReference, Posted, ProcessedOn, Processing, Ref_Invoice_ID, Reversal_ID, SendEMail, TotalLines, A_Asset_ID, Fact_Acct_AD_Org_ID, Fact_Acct_AD_OrgTrx_ID, Fact_Acct_AD_Table_ID, Fact_Acct_C_Activity_ID, Fact_Acct_C_BPartner_ID, Fact_Acct_C_Campaign_ID, Fact_Acct_C_Currency_ID, C_SubAcct_ID, fact_acct_dateacct, DateTrx, fact_acct_description, fact_acct_isactive, Line_ID, Fact_Acct_M_Product_ID, Record_ID, fact_acct_updated, Fact_Acct_UpdatedBy, Fact_Acct_User1_ID, Fact_Acct_User2_ID, UserElement1_ID, UserElement2_ID) AS SELECT i.ad_client_id AS AD_Client_ID, i.ad_org_id AS AD_Org_ID, i.isactive AS IsActive, i.created AS Created, i.createdby AS CreatedBy, i.updated AS Updated, i.updatedby AS UpdatedBy, i.c_invoice_id AS C_Invoice_ID, i.issotrx AS IsSOTrx, i.documentno AS DocumentNo, i.docstatus AS DocStatus, i.c_doctype_id AS C_DocType_ID, i.c_order_id AS C_Order_ID, i.description AS Description, i.salesrep_id AS SalesRep_ID, i.dateinvoiced AS DateInvoiced, i.dateacct AS DateAcct, i.c_paymentterm_id AS C_PaymentTerm_ID, i.c_bpartner_id AS C_BPartner_ID, i.c_bpartner_location_id AS C_BPartner_Location_ID, i.ad_user_id AS AD_User_ID, i.isselfservice AS IsSelfService, i.c_currency_id AS C_Currency_ID, i.c_conversiontype_id AS C_ConversionType_ID, i.grandtotal AS GrandTotal, i.istaxincluded AS IsTaxIncluded, i.c_campaign_id AS C_Campaign_ID, i.c_project_id AS C_Project_ID, i.c_activity_id AS C_Activity_ID, i.ad_orgtrx_id AS AD_OrgTrx_ID, i.user1_id AS User1_ID, i.user2_id AS User2_ID, fa.c_locfrom_id AS C_LocFrom_ID, fa.c_locto_id AS C_LocTo_ID, fa.c_salesregion_id AS C_SalesRegion_ID, fa.fact_acct_id AS Fact_Acct_ID, fa.c_acctschema_id AS C_AcctSchema_ID, fa.account_id AS Account_ID, fa.c_period_id AS C_Period_ID, fa.gl_category_id AS GL_Category_ID, fa.gl_budget_id AS GL_Budget_ID, fa.c_tax_id AS C_Tax_ID, fa.m_locator_id AS M_Locator_ID, fa.postingtype AS PostingType, fa.amtsourcedr AS AmtSourceDr, fa.amtsourcecr AS AmtSourceCr, fa.amtacctdr AS AmtAcctDr, fa.amtacctcr AS AmtAcctCr, fa.c_uom_id AS C_UOM_ID, fa.qty AS Qty, gl.ad_pinstance_id AS AD_PInstance_ID, gl.apar AS APAR, gl.openamt AS OpenAmt, gl.percent AS Percent, gl.amtrevaldr AS AmtRevalDr, gl.amtrevalcr AS AmtRevalCr, gl.datereval AS DateReval, gl.c_conversiontypereval_id AS C_ConversionTypeReval_ID, gl.amtsourcebalance AS AmtSourceBalance, gl.amtacctbalance AS AmtAcctBalance, gl.c_doctypereval_id AS C_DocTypeReval_ID, gl.amtrevaldrdiff AS AmtRevalDrDiff, gl.amtrevalcrdiff AS AmtRevalCrDiff, gl.isallcurrencies AS IsAllCurrencies, fa.amtacctdr * gl.percent / 100 AS AmtAcctOpenDr, fa.amtacctcr * gl.percent / 100 AS AmtAcctOpenCr, (fa.amtacctdr - fa.amtacctc
;
-- Nov 28, 2021, 11:19:15 PM CET
CREATE OR REPLACE VIEW M_InOutLineMA_v(AD_Client_ID, AD_Org_ID, IsActive, Created, CreatedBy, Updated, UpdatedBy, M_InOut_ID, M_InOutLine_ID, Line, M_Product_ID, M_AttributeSetInstance_ID, MovementQty, M_Locator_ID) AS SELECT m.ad_client_id AS AD_Client_ID, m.ad_org_id AS AD_Org_ID, m.isactive AS IsActive, m.created AS Created, m.createdby AS CreatedBy, m.updated AS Updated, m.updatedby AS UpdatedBy, l.m_inout_id AS M_InOut_ID, m.m_inoutline_id AS M_InOutLine_ID, l.line AS Line, l.m_product_id AS M_Product_ID, m.m_attributesetinstance_id AS M_AttributeSetInstance_ID, m.movementqty AS MovementQty, l.m_locator_id AS M_Locator_ID FROM m_inoutlinema m JOIN m_inoutline l ON m.m_inoutline_id = l.m_inoutline_id UNION SELECT m_inoutline.ad_client_id AS AD_Client_ID, m_inoutline.ad_org_id AS AD_Org_ID, m_inoutline.isactive AS IsActive, m_inoutline.created AS Created, m_inoutline.createdby AS CreatedBy, m_inoutline.updated AS Updated, m_inoutline.updatedby AS UpdatedBy, m_inoutline.m_inout_id AS M_InOut_ID, m_inoutline.m_inoutline_id AS M_InOutLine_ID, m_inoutline.line AS Line, m_inoutline.m_product_id AS M_Product_ID, m_inoutline.m_attributesetinstance_id AS M_AttributeSetInstance_ID, m_inoutline.movementqty AS MovementQty, m_inoutline.m_locator_id AS M_Locator_ID FROM m_inoutline
;
-- Nov 28, 2021, 11:19:15 PM CET
CREATE OR REPLACE VIEW M_MovementLineMA_v(AD_Client_ID, AD_Org_ID, IsActive, Created, CreatedBy, Updated, UpdatedBy, M_Movement_ID, M_MovementLine_ID, Line, M_Product_ID, M_AttributeSetInstance_ID, MovementQty, M_Locator_ID, M_LocatorTo_ID) AS SELECT m.ad_client_id AS AD_Client_ID, m.ad_org_id AS AD_Org_ID, m.isactive AS IsActive, m.created AS Created, m.createdby AS CreatedBy, m.updated AS Updated, m.updatedby AS UpdatedBy, l.m_movement_id AS M_Movement_ID, m.m_movementline_id AS M_MovementLine_ID, l.line AS Line, l.m_product_id AS M_Product_ID, m.m_attributesetinstance_id AS M_AttributeSetInstance_ID, m.movementqty AS MovementQty, l.m_locator_id AS M_Locator_ID, l.m_locatorto_id AS M_LocatorTo_ID FROM m_movementlinema m JOIN m_movementline l ON m.m_movementline_id = l.m_movementline_id UNION SELECT m_movementline.ad_client_id AS AD_Client_ID, m_movementline.ad_org_id AS AD_Org_ID, m_movementline.isactive AS IsActive, m_movementline.created AS Created, m_movementline.createdby AS CreatedBy, m_movementline.updated AS Updated, m_movementline.updatedby AS UpdatedBy, m_movementline.m_movement_id AS M_Movement_ID, m_movementline.m_movementline_id AS M_MovementLine_ID, m_movementline.line AS Line, m_movementline.m_product_id AS M_Product_ID, m_movementline.m_attributesetinstance_id AS M_AttributeSetInstance_ID, m_movementline.movementqty AS MovementQty, m_movementline.m_locator_id AS M_Locator_ID, m_movementline.m_locatorto_id AS M_LocatorTo_ID FROM m_movementline
;
-- Nov 28, 2021, 11:19:15 PM CET
CREATE OR REPLACE VIEW RV_M_Transaction(AD_Client_ID, AD_Org_ID, MovementDate, MovementQty, M_Product_ID, M_Locator_ID, M_AttributeSetInstance_ID, M_Product_Category_ID, Value, C_BPartner_ID, PricePO, PriceLastPO, PriceList, C_ProjectIssue_ID, m_transaction_created, M_Transaction_CreatedBy, m_transaction_isactive, M_InOutLine_ID, MovementType, M_ProductionLine_ID, M_Transaction_ID, PP_Cost_Collector_ID, m_transation_updated, M_Transation_UpdatedBy, 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, m_product_description, DescriptionURL, m_product_discontinued, m_product_discontinuedat, DocumentNote, Group1, Group2, GuaranteeDays, GuaranteeDaysMin, Help, ImageURL, m_product_isactive, IsDropShip, IsExcludeAutoDelivery, IsInvoicePrintDetails, IsPickListPrintDetails, IsPurchased, IsSelfService, IsSold, IsStocked, m_product_issummary, IsVerified, IsWebStoreFeatured, LowLevel, M_Product_M_AttributeSet_ID, M_Product_M_ASI_ID, M_FreightCategory_ID, M_Product_M_Locator_ID, m_product_name, m_product_processing, ProductType, R_MailText_ID, M_Product_SalesRep_ID, S_ExpenseType_ID, ShelfDepth, ShelfHeight, ShelfWidth, SKU, S_Resource_ID, UnitsPerPack, UnitsPerPallet, m_product_upc, m_product_updated, M_Product_UpdatedBy, VersionNo, Volume, Weight, M_Product_PO_AD_Org_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, Manufacturer, M_Product_PO_M_Product_ID, Order_Min, Order_Pack, PriceEffective, PriceLastInv, QualityRating, RoyaltyAmt, m_product_po_upc, m_product_po_updated, M_Product_PO_UpdatedBy, VendorCategory, VendorProductNo) AS SELECT t.ad_client_id AS AD_Client_ID, t.ad_org_id AS AD_Org_ID, t.movementdate AS MovementDate, t.movementqty AS MovementQty, t.m_product_id AS M_Product_ID, t.m_locator_id AS M_Locator_ID, t.m_attributesetinstance_id AS M_AttributeSetInstance_ID, p.m_product_category_id AS M_Product_Category_ID, p.value AS Value, po.c_bpartner_id AS C_BPartner_ID, po.pricepo AS PricePO, po.pricelastpo AS PriceLastPO, po.pricelist AS PriceList, t.c_projectissue_id AS C_ProjectIssue_ID, t.created AS m_transaction_created, t.createdby AS M_Transaction_CreatedBy, t.isactive AS m_transaction_isactive, t.m_inoutline_id AS M_InOutLine_ID, t.movementtype AS MovementType, t.m_productionline_id AS M_ProductionLine_ID, t.m_transaction_id AS M_Transaction_ID, t.pp_cost_collector_id AS PP_Cost_Collector_ID, t.updated AS m_transation_updated, t.updatedby AS M_Transation_UpdatedBy, p.ad_org_id AS M_Product_AD_Org_ID, p.classification 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.description AS m_product_description, p.descriptionurl AS DescriptionURL, p.discontinued AS m_product_discontinued, p.discontinuedat AS m_product_discontinuedat, p.documentnote AS DocumentNote, p.group1 AS Group1, p.group2 AS Group2, p.guaranteedays AS GuaranteeDays, p.guaranteedaysmin AS GuaranteeDaysMin, p.help AS Help, p.imageurl AS ImageURL, p.isactive AS m_product_isactive, p.isdropship AS IsDropShip, p.isexcludeautodelivery AS IsExcludeAutoDelivery, p.isinvoiceprintdetails AS IsInvoicePrintDetails, p.ispicklistprintdetails AS IsPickListPrintDetails, p.ispurchased AS IsPurchased, p.isselfservice AS 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_Product_M_AttributeSet_ID, p.m_attributesetinstance_id AS M_Product_M_ASI_ID, p.m_freightcategory_id AS M_FreightCategory_ID, p.m_locator_id AS M_Product_M_Locator_
;
-- Nov 28, 2021, 11:19:15 PM CET
CREATE OR REPLACE VIEW RV_C_RfQ_UnAnswered(AD_Client_ID, AD_Org_ID, C_RfQ_ID, Name, Description, Help, SalesRep_ID, C_RfQ_Topic_ID, QuoteType, IsQuoteTotalAmt, IsQuoteAllQty, C_Currency_ID, DateResponse, IsRfQResponseAccepted, DateWorkStart, DeliveryDays, DateWorkComplete, C_BPartner_ID, C_BPartner_Location_ID, AD_User_ID) AS SELECT q.ad_client_id AS AD_Client_ID, q.ad_org_id AS AD_Org_ID, q.c_rfq_id AS C_RfQ_ID, q.name AS Name, q.description AS Description, q.help AS Help, q.salesrep_id AS SalesRep_ID, q.c_rfq_topic_id AS C_RfQ_Topic_ID, q.quotetype AS QuoteType, q.isquotetotalamt AS IsQuoteTotalAmt, q.isquoteallqty AS IsQuoteAllQty, q.c_currency_id AS C_Currency_ID, q.dateresponse AS DateResponse, q.isrfqresponseaccepted AS IsRfQResponseAccepted, q.dateworkstart AS DateWorkStart, q.deliverydays AS DeliveryDays, q.dateworkcomplete AS DateWorkComplete, r.c_bpartner_id AS C_BPartner_ID, r.c_bpartner_location_id AS C_BPartner_Location_ID, r.ad_user_id AS AD_User_ID FROM c_rfq q JOIN c_rfqresponse r ON q.c_rfq_id = r.c_rfq_id WHERE r.iscomplete = 'N' AND q.processed = 'N'
;
-- Nov 28, 2021, 11:19:15 PM CET
CREATE OR REPLACE VIEW RV_C_RfQResponse(AD_Client_ID, AD_Org_ID, C_RfQ_ID, C_RfQ_Topic_ID, C_BPartner_ID, C_BPartner_Location_ID, AD_User_ID, C_RfQResponse_ID, C_Currency_ID, DateResponse, DateWorkStart, DeliveryDays, DateWorkComplete, Price, Ranking, IsSelfService, Description, Help, M_Product_ID, M_AttributeSetInstance_ID, Line, LineDateWorkStart, LineDeliveryDays, LineDateWorkComplete, LineDescription, LineHelp, C_UOM_ID, Qty, BenchmarkPrice, BenchmarkDifference, QtyPrice, Discount, QtyRanking) AS SELECT q.ad_client_id AS AD_Client_ID, q.ad_org_id AS AD_Org_ID, q.c_rfq_id AS C_RfQ_ID, q.c_rfq_topic_id AS C_RfQ_Topic_ID, r.c_bpartner_id AS C_BPartner_ID, r.c_bpartner_location_id AS C_BPartner_Location_ID, r.ad_user_id AS AD_User_ID, r.c_rfqresponse_id AS C_RfQResponse_ID, r.c_currency_id AS C_Currency_ID, r.dateresponse AS DateResponse, r.dateworkstart AS DateWorkStart, r.deliverydays AS DeliveryDays, r.dateworkcomplete AS DateWorkComplete, r.price AS Price, r.ranking AS Ranking, r.isselfservice AS IsSelfService, r.description AS Description, r.help AS Help, ql.m_product_id AS M_Product_ID, ql.m_attributesetinstance_id AS M_AttributeSetInstance_ID, ql.line AS Line, rl.dateworkstart AS LineDateWorkStart, rl.deliverydays AS LineDeliveryDays, rl.dateworkcomplete AS LineDateWorkComplete, rl.description AS LineDescription, rl.help AS LineHelp, qlq.c_uom_id AS C_UOM_ID, qlq.qty AS Qty, qlq.benchmarkprice AS BenchmarkPrice, rlq.price - qlq.benchmarkprice AS BenchmarkDifference, rlq.price AS QtyPrice, rlq.discount AS Discount, rlq.ranking AS QtyRanking FROM c_rfq q JOIN c_rfqline ql ON q.c_rfq_id = ql.c_rfq_id JOIN c_rfqlineqty qlq ON ql.c_rfqline_id = qlq.c_rfqline_id JOIN c_rfqresponse r ON q.c_rfq_id = r.c_rfq_id JOIN c_rfqresponseline rl ON r.c_rfqresponse_id = rl.c_rfqresponse_id AND ql.c_rfqline_id = rl.c_rfqline_id JOIN c_rfqresponselineqty rlq ON rl.c_rfqresponseline_id = rlq.c_rfqresponseline_id AND qlq.c_rfqlineqty_id = rlq.c_rfqlineqty_id WHERE r.iscomplete = 'Y' AND q.processed = 'N'
;
-- Nov 28, 2021, 11:19:15 PM CET
CREATE OR REPLACE VIEW M_InOutConfirm_v(AD_Client_ID, AD_Org_ID, IsActive, Created, CreatedBy, Updated, UpdatedBy, AD_Language, M_InOutConfirm_ID, DocumentNo, ConfirmType, IsApproved, IsCancelled, Description, M_InOut_ID, ShipDescription, C_BPartner_ID, C_BPartner_Location_ID, AD_User_ID, SalesRep_ID, C_DocType_ID, DocumentType, C_Order_ID, DateOrdered, MovementDate, MovementType, M_Warehouse_ID, POReference, DeliveryRule, FreightCostRule, DeliveryViaRule, M_Shipper_ID, PriorityRule, Processed) AS SELECT ioc.ad_client_id AS AD_Client_ID, ioc.ad_org_id AS AD_Org_ID, ioc.isactive AS IsActive, ioc.created AS Created, ioc.createdby AS CreatedBy, ioc.updated AS Updated, ioc.updatedby AS UpdatedBy, CAST('en_US' AS CHARACTER VARYING(6)) AS AD_Language, ioc.m_inoutconfirm_id AS M_InOutConfirm_ID, ioc.documentno AS DocumentNo, ioc.confirmtype AS ConfirmType, ioc.isapproved AS IsApproved, ioc.iscancelled AS IsCancelled, ioc.description AS Description, io.m_inout_id AS M_InOut_ID, io.description AS ShipDescription, io.c_bpartner_id AS C_BPartner_ID, io.c_bpartner_location_id AS C_BPartner_Location_ID, io.ad_user_id AS AD_User_ID, io.salesrep_id AS SalesRep_ID, io.c_doctype_id AS C_DocType_ID, dt.printname AS DocumentType, io.c_order_id AS C_Order_ID, io.dateordered AS DateOrdered, io.movementdate AS MovementDate, io.movementtype AS MovementType, io.m_warehouse_id AS M_Warehouse_ID, io.poreference AS POReference, io.deliveryrule AS DeliveryRule, io.freightcostrule AS FreightCostRule, io.deliveryviarule AS DeliveryViaRule, io.m_shipper_id AS M_Shipper_ID, io.priorityrule AS PriorityRule, ioc.processed AS Processed FROM m_inoutconfirm ioc JOIN m_inout io ON ioc.m_inout_id = io.m_inout_id JOIN c_doctype dt ON io.c_doctype_id = dt.c_doctype_id
;
-- Nov 28, 2021, 11:19:15 PM CET
CREATE OR REPLACE VIEW RV_Allocation(C_AllocationHdr_ID, AD_Client_ID, AD_Org_ID, IsActive, Created, CreatedBy, Updated, UpdatedBy, DocumentNo, Description, DateTrx, DateAcct, C_Currency_ID, ApprovalAmt, IsManual, DocStatus, DocAction, Processed, C_AllocationLine_ID, C_Invoice_ID, C_BPartner_ID, C_Order_ID, C_Payment_ID, C_CashLine_ID, Amount, DiscountAmt, WriteOffAmt, OverUnderAmt, IsApproved, Posted, C_AllocationLine_AD_Org_ID, c_allocationline_created, C_AllocationLine_CreatedBy, c_allocationline_datetrx, c_allocationline_isactive, c_allocationline_ismanual, c_allocationline_updated, C_AllocationLine_UpdatedBy) AS SELECT h.c_allocationhdr_id AS C_AllocationHdr_ID, h.ad_client_id AS AD_Client_ID, h.ad_org_id AS AD_Org_ID, h.isactive AS IsActive, h.created AS Created, h.createdby AS CreatedBy, h.updated AS Updated, h.updatedby AS UpdatedBy, h.documentno AS DocumentNo, h.description AS Description, h.datetrx AS DateTrx, h.dateacct AS DateAcct, h.c_currency_id AS C_Currency_ID, h.approvalamt AS ApprovalAmt, h.ismanual AS IsManual, h.docstatus AS DocStatus, h.docaction AS DocAction, h.processed AS Processed, l.c_allocationline_id AS C_AllocationLine_ID, l.c_invoice_id AS C_Invoice_ID, l.c_bpartner_id AS C_BPartner_ID, l.c_order_id AS C_Order_ID, l.c_payment_id AS C_Payment_ID, l.c_cashline_id AS C_CashLine_ID, l.amount AS Amount, l.discountamt AS DiscountAmt, l.writeoffamt AS WriteOffAmt, l.overunderamt AS OverUnderAmt, h.isapproved AS IsApproved, h.posted AS Posted, l.ad_org_id AS C_AllocationLine_AD_Org_ID, l.created AS c_allocationline_created, l.createdby AS C_AllocationLine_CreatedBy, l.datetrx AS c_allocationline_datetrx, l.isactive AS c_allocationline_isactive, l.ismanual AS c_allocationline_ismanual, l.updated AS c_allocationline_updated, l.updatedby AS C_AllocationLine_UpdatedBy FROM c_allocationhdr h JOIN c_allocationline l ON h.c_allocationhdr_id = l.c_allocationhdr_id
;
-- Nov 28, 2021, 11:19:15 PM CET
CREATE OR REPLACE VIEW RV_CostSummary(AD_Client_ID, AD_Org_ID, IsActive, CreatedBy, Created, UpdatedBy, Updated, M_Product_ID, Value, Name, UPC, IsBOM, ProductType, M_Product_Category_ID, M_CostType_ID, C_AcctSchema_ID, C_Currency_ID, CurrentCostPrice, FutureCostPrice) AS SELECT c.ad_client_id AS AD_Client_ID, c.ad_org_id AS AD_Org_ID, c.isactive AS IsActive, 0 AS CreatedBy, statement_timestamp() AS Created, 0 AS UpdatedBy, statement_timestamp() AS Updated, p.m_product_id AS M_Product_ID, p.value AS Value, p.name AS Name, p.upc AS UPC, p.isbom AS IsBOM, p.producttype AS ProductType, p.m_product_category_id AS M_Product_Category_ID, c.m_costtype_id AS M_CostType_ID, acct.c_acctschema_id AS C_AcctSchema_ID, acct.c_currency_id AS C_Currency_ID, sum(c.currentcostprice) AS CurrentCostPrice, sum(c.futurecostprice) AS FutureCostPrice FROM m_cost c JOIN m_product p ON c.m_product_id = p.m_product_id JOIN c_acctschema acct ON c.c_acctschema_id = acct.c_acctschema_id WHERE acct.m_costtype_id = c.m_costtype_id GROUP BY c.ad_client_id, c.ad_org_id, c.isactive, p.m_product_id, p.value, p.name, p.upc, p.isbom, p.producttype, p.m_product_category_id, c.m_costtype_id, acct.c_acctschema_id, acct.c_currency_id
;
-- Nov 28, 2021, 11:19:15 PM CET
CREATE OR REPLACE VIEW RV_CostDetail(AD_Client_ID, AD_Org_ID, IsActive, Created, CreatedBy, Updated, UpdatedBy, M_Product_ID, Value, Name, UPC, IsBOM, ProductType, M_Product_Category_ID, M_InOutLine_ID, C_InvoiceLine_ID, M_AttributeSetInstance_ID, M_AttributeSet_ID, Lot, SerNo, C_AcctSchema_ID, C_Currency_ID, Amt, Qty, Description, Processed, C_OrderLine_ID, C_ProjectIssue_ID, CumulatedAmt, CumulatedQty, CurrentCostPrice, CurrentQty, DeltaAmt, DeltaQty, IsSOTrx, M_CostDetail_ID, M_CostElement_ID, M_InventoryLine_ID, M_MovementLine_ID, M_ProductionLine_ID, PP_Cost_Collector_ID, M_Product_AD_Org_ID, Classification, m_product_copyfrom, m_product_created, M_Product_CreatedBy, C_RevenueRecognition_ID, C_SubscriptionType_ID, C_TaxCategory_ID, C_UOM_ID, m_product_description, DescriptionURL, Discontinued, DiscontinuedAt, DocumentNote, Group1, Group2, GuaranteeDays, GuaranteeDaysMin, Help, ImageURL, m_product_isactive, IsDropShip, IsExcludeAutoDelivery, IsInvoicePrintDetails, IsPickListPrintDetails, IsPurchased, IsSelfService, IsSold, IsStocked, m_product_issummary, IsVerified, IsWebStoreFeatured, LowLevel, M_Product_M_AttributeSet_ID, M_Product_M_ASI_ID, M_FreightCategory_ID, M_Locator_ID, m_product_processing, R_MailText_ID, M_Product_SalesRep_ID, S_ExpenseType_ID, ShelfDepth, ShelfHeight, ShelfWidth, SKU, S_Resource_ID, UnitsPerPack, UnitsPerPallet, m_product_updated, M_Product_UpdatedBy, VersionNo, Volume, Weight, C_AcctSchema_AD_Org_ID, c_acctschema_description, c_acctschema_name, M_ASI_AD_Org_ID, m_asi_created, M_ASI_CreatedBy, M_ASI_Description, GuaranteeDate, m_asi_isactive, M_Lot_ID, m_asi_updated, M_ASI_UpdatedBy) AS SELECT c.ad_client_id AS AD_Client_ID, c.ad_org_id AS AD_Org_ID, c.isactive AS IsActive, c.created AS Created, c.createdby AS CreatedBy, c.updated AS Updated, c.updatedby AS UpdatedBy, p.m_product_id AS M_Product_ID, p.value AS Value, p.name AS Name, p.upc AS UPC, p.isbom AS IsBOM, p.producttype AS ProductType, p.m_product_category_id AS M_Product_Category_ID, c.m_inoutline_id AS M_InOutLine_ID, c.c_invoiceline_id AS C_InvoiceLine_ID, asi.m_attributesetinstance_id AS M_AttributeSetInstance_ID, asi.m_attributeset_id AS M_AttributeSet_ID, asi.lot AS Lot, asi.serno AS SerNo, acct.c_acctschema_id AS C_AcctSchema_ID, acct.c_currency_id AS C_Currency_ID, c.amt AS Amt, c.qty AS Qty, c.description AS Description, c.processed AS Processed, c.c_orderline_id AS C_OrderLine_ID, c.c_projectissue_id AS C_ProjectIssue_ID, c.cumulatedamt AS CumulatedAmt, c.cumulatedqty AS CumulatedQty, c.currentcostprice AS CurrentCostPrice, c.currentqty AS CurrentQty, c.deltaamt AS DeltaAmt, c.deltaqty AS DeltaQty, c.issotrx AS IsSOTrx, c.m_costdetail_id AS M_CostDetail_ID, c.m_costelement_id AS M_CostElement_ID, c.m_inventoryline_id AS M_InventoryLine_ID, c.m_movementline_id AS M_MovementLine_ID, c.m_productionline_id AS M_ProductionLine_ID, c.pp_cost_collector_id AS PP_Cost_Collector_ID, 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 C_UOM_ID, p.description AS m_product_description, p.descriptionurl AS DescriptionURL, p.discontinued AS Discontinued, p.discontinuedat AS DiscontinuedAt, p.documentnote AS DocumentNote, p.group1 AS Group1, p.group2 AS Group2, p.guaranteedays AS GuaranteeDays, p.guaranteedaysmin AS GuaranteeDaysMin, p.help AS Help, p.imageurl AS ImageURL, p.isactive AS m_product_isactive, p.isdropship AS IsDropShip, p.isexcludeautodelivery AS IsExcludeAutoDelivery, p.isinvoiceprintdetails AS IsInvoicePrintDetails, p.ispicklistprintdetails AS IsPickListPrintDetails, p.ispurchased AS IsPurchased, p.isselfservice AS 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_Product_M_Attrib
;
-- Nov 28, 2021, 11:19:15 PM CET
CREATE OR REPLACE VIEW RV_C_Invoice_ProductQtr(AD_Client_ID, AD_Org_ID, M_Product_ID, DateInvoiced, LineNetAmt, LineListAmt, LineLimitAmt, LineDiscountAmt, LineDiscount, LineOverLimitAmt, LineOverLimit, QtyInvoiced, IsSOTrx) AS SELECT il.ad_client_id AS AD_Client_ID, il.ad_org_id AS AD_Org_ID, il.m_product_id AS M_Product_ID, firstof(il.dateinvoiced, 'Q') AS DateInvoiced, sum(il.linenetamt) AS LineNetAmt, sum(il.linelistamt) AS LineListAmt, sum(il.linelimitamt) AS LineLimitAmt, sum(il.linediscountamt) AS LineDiscountAmt, CASE WHEN sum(il.linelistamt) = 0 THEN 0 ELSE currencyround((sum(il.linelistamt) - sum(il.linenetamt)) / sum(il.linelistamt) * 100, i.c_currency_id, 'N') END AS LineDiscount, sum(il.lineoverlimitamt) AS LineOverLimitAmt, CASE WHEN sum(il.linenetamt) = 0 THEN 0 ELSE 100 - currencyround((sum(il.linenetamt) - sum(il.lineoverlimitamt)) / sum(il.linenetamt) * 100, i.c_currency_id, 'N') END AS LineOverLimit, sum(il.qtyinvoiced) AS QtyInvoiced, il.issotrx AS IsSOTrx FROM rv_c_invoiceline il JOIN c_invoice i ON i.c_invoice_id = il.c_invoice_id GROUP BY il.ad_client_id, il.ad_org_id, il.m_product_id, (firstof(il.dateinvoiced, 'Q')), il.issotrx, i.c_currency_id
;
-- Nov 28, 2021, 11:19:15 PM CET
CREATE OR REPLACE VIEW RV_C_Invoice_ProductMonth(AD_Client_ID, AD_Org_ID, M_Product_ID, DateInvoiced, LineNetAmt, LineListAmt, LineLimitAmt, LineDiscountAmt, LineDiscount, LineOverLimitAmt, LineOverLimit, QtyInvoiced, IsSOTrx) AS SELECT il.ad_client_id AS AD_Client_ID, il.ad_org_id AS AD_Org_ID, il.m_product_id AS M_Product_ID, firstof(il.dateinvoiced, 'MM') AS DateInvoiced, sum(il.linenetamt) AS LineNetAmt, sum(il.linelistamt) AS LineListAmt, sum(il.linelimitamt) AS LineLimitAmt, sum(il.linediscountamt) AS LineDiscountAmt, CASE WHEN sum(il.linelistamt) = 0 THEN 0 ELSE currencyround((sum(il.linelistamt) - sum(il.linenetamt)) / sum(il.linelistamt) * 100, i.c_currency_id, 'N') END AS LineDiscount, sum(il.lineoverlimitamt) AS LineOverLimitAmt, CASE WHEN sum(il.linenetamt) = 0 THEN 0 ELSE 100 - currencyround((sum(il.linenetamt) - sum(il.lineoverlimitamt)) / sum(il.linenetamt) * 100, i.c_currency_id, 'N') END AS LineOverLimit, sum(il.qtyinvoiced) AS QtyInvoiced, il.issotrx AS IsSOTrx FROM rv_c_invoiceline il JOIN c_invoice i ON i.c_invoice_id = il.c_invoice_id GROUP BY il.ad_client_id, il.ad_org_id, il.m_product_id, (firstof(il.dateinvoiced, 'MM')), il.issotrx, i.c_currency_id
;
-- Nov 28, 2021, 11:19:15 PM CET
CREATE OR REPLACE VIEW C_RfQResponseLine_v(C_RfQResponse_ID, C_RfQResponseLine_ID, C_RfQLine_ID, C_RfQResponseLineQty_ID, C_RfQLineQty_ID, AD_Client_ID, AD_Org_ID, IsActive, Created, CreatedBy, Updated, UpdatedBy, AD_Language, Line, M_Product_ID, M_AttributeSetInstance_ID, Name, Description, DocumentNote, UPC, SKU, ProductValue, Help, DateWorkStart, DeliveryDays, C_UOM_ID, UOMSymbol, BenchmarkPrice, Qty, Price, Discount) AS SELECT rrl.c_rfqresponse_id AS C_RfQResponse_ID, rrl.c_rfqresponseline_id AS C_RfQResponseLine_ID, rrl.c_rfqline_id AS C_RfQLine_ID, rq.c_rfqresponselineqty_id AS C_RfQResponseLineQty_ID, rq.c_rfqlineqty_id AS C_RfQLineQty_ID, rrl.ad_client_id AS AD_Client_ID, rrl.ad_org_id AS AD_Org_ID, rrl.isactive AS IsActive, rrl.created AS Created, rrl.createdby AS CreatedBy, rrl.updated AS Updated, rrl.updatedby AS UpdatedBy, CAST('en_US' AS CHARACTER VARYING(6)) AS AD_Language, rl.line AS Line, rl.m_product_id AS M_Product_ID, rl.m_attributesetinstance_id AS M_AttributeSetInstance_ID, COALESCE(p.name || productattribute(rl.m_attributesetinstance_id), rl.description) AS Name, CASE WHEN p.name IS NOT NULL THEN rl.description ELSE NULL END AS Description, p.documentnote AS DocumentNote, p.upc AS UPC, p.sku AS SKU, p.value AS ProductValue, rl.help AS Help, rl.dateworkstart AS DateWorkStart, rl.deliverydays AS DeliveryDays, q.c_uom_id AS C_UOM_ID, uom.uomsymbol AS UOMSymbol, q.benchmarkprice AS BenchmarkPrice, q.qty AS Qty, rq.price AS Price, rq.discount AS Discount FROM c_rfqresponselineqty rq JOIN c_rfqlineqty q ON rq.c_rfqlineqty_id = q.c_rfqlineqty_id JOIN c_uom uom ON q.c_uom_id = uom.c_uom_id JOIN c_rfqresponseline rrl ON rq.c_rfqresponseline_id = rrl.c_rfqresponseline_id JOIN c_rfqline rl ON rrl.c_rfqline_id = rl.c_rfqline_id LEFT JOIN m_product p ON rl.m_product_id = p.m_product_id WHERE rq.isactive = 'Y' AND q.isactive = 'Y' AND rrl.isactive = 'Y' AND rl.isactive = 'Y'
;
-- Nov 28, 2021, 11:19:15 PM CET
CREATE OR REPLACE VIEW C_RfQResponse_v(C_RfQResponse_ID, C_RfQ_ID, AD_Client_ID, AD_Org_ID, IsActive, Created, CreatedBy, Updated, UpdatedBy, AD_Language, Org_Location_ID, TaxID, Name, Description, Help, C_Currency_ID, ISO_Code, DateResponse, DateWorkStart, DeliveryDays, C_BPartner_ID, BPName, BPName2, C_BPartner_Location_ID, C_Location_ID, AD_User_ID, Title, Phone, ContactName) AS SELECT rr.c_rfqresponse_id AS C_RfQResponse_ID, rr.c_rfq_id AS C_RfQ_ID, rr.ad_client_id AS AD_Client_ID, rr.ad_org_id AS AD_Org_ID, rr.isactive AS IsActive, rr.created AS Created, rr.createdby AS CreatedBy, rr.updated AS Updated, rr.updatedby AS UpdatedBy, CAST('en_US' AS CHARACTER VARYING(6)) AS AD_Language, oi.c_location_id AS Org_Location_ID, oi.taxid AS TaxID, r.name AS Name, r.description AS Description, r.help AS Help, r.c_currency_id AS C_Currency_ID, c.iso_code AS ISO_Code, r.dateresponse AS DateResponse, r.dateworkstart AS DateWorkStart, r.deliverydays AS DeliveryDays, rr.c_bpartner_id AS C_BPartner_ID, bp.name AS BPName, bp.name2 AS BPName2, rr.c_bpartner_location_id AS C_BPartner_Location_ID, bpl.c_location_id AS C_Location_ID, rr.ad_user_id AS AD_User_ID, bpc.title AS Title, bpc.phone AS Phone, NULLIF(bpc.name, bp.name) AS ContactName FROM c_rfqresponse rr JOIN c_rfq r ON rr.c_rfq_id = r.c_rfq_id JOIN ad_orginfo oi ON rr.ad_org_id = oi.ad_org_id JOIN c_currency c ON r.c_currency_id = c.c_currency_id JOIN c_bpartner bp ON rr.c_bpartner_id = bp.c_bpartner_id JOIN c_bpartner_location bpl ON rr.c_bpartner_location_id = bpl.c_bpartner_location_id LEFT JOIN ad_user bpc ON rr.ad_user_id = bpc.ad_user_id
;
-- Nov 28, 2021, 11:19:15 PM CET
CREATE OR REPLACE VIEW C_RfQResponseLineQty_v(C_RfQResponseLine_ID, C_RfQResponseLineQty_ID, C_RfQLineQty_ID, AD_Client_ID, AD_Org_ID, IsActive, Created, CreatedBy, Updated, UpdatedBy, AD_Language, C_UOM_ID, UOMSymbol, Qty, Price, Discount) AS SELECT rq.c_rfqresponseline_id AS C_RfQResponseLine_ID, rq.c_rfqresponselineqty_id AS C_RfQResponseLineQty_ID, rq.c_rfqlineqty_id AS C_RfQLineQty_ID, rq.ad_client_id AS AD_Client_ID, rq.ad_org_id AS AD_Org_ID, rq.isactive AS IsActive, rq.created AS Created, rq.createdby AS CreatedBy, rq.updated AS Updated, rq.updatedby AS UpdatedBy, CAST('en_US' AS CHARACTER VARYING(6)) AS AD_Language, q.c_uom_id AS C_UOM_ID, uom.uomsymbol AS UOMSymbol, q.qty AS Qty, rq.price AS Price, rq.discount AS Discount FROM c_rfqresponselineqty rq JOIN c_rfqlineqty q ON rq.c_rfqlineqty_id = q.c_rfqlineqty_id JOIN c_uom uom ON q.c_uom_id = uom.c_uom_id WHERE rq.isactive = 'Y' AND q.isactive = 'Y'
;
-- Nov 28, 2021, 11:19:15 PM CET
CREATE OR REPLACE VIEW C_Invoice_Header_v(AD_Client_ID, AD_Org_ID, IsActive, Created, CreatedBy, Updated, UpdatedBy, AD_Language, C_Invoice_ID, IsSOTrx, DocumentNo, DocStatus, C_DocType_ID, C_BPartner_ID, BPValue, BPTaxID, NAICS, DUNS, Org_Location_ID, TaxID, DocumentType, DocumentTypeNote, C_Order_ID, SalesRep_ID, SalesRep_Name, DateInvoiced, BPGreeting, Name, Name2, BPContactGreeting, Title, Phone, ContactName, C_Location_ID, ReferenceNo, Postal, Description, POReference, DateOrdered, C_Currency_ID, PaymentTerm, PaymentTermNote, C_Charge_ID, ChargeAmt, TotalLines, GrandTotal, AmtInWords, M_PriceList_ID, IsTaxIncluded, C_Campaign_ID, C_Project_ID, C_Activity_ID, IsPaid, Logo_ID, C_Invoice_AD_OrgTrx_ID, AD_User_ID, C_BPartner_Location_ID, C_ConversionType_ID, C_DocTypeTarget_ID, C_DunningLevel_ID, C_Payment_ID, DateAcct, DatePrinted, DocAction, DunningGrace, GenerateTo, InvoiceCollectionType, IsApproved, IsDiscountPrinted, IsInDispute, IsPayScheduleValid, IsPrinted, c_invoice_isselfservice, IsTransferred, M_RMA_ID, PaymentRule, Posted, ProcessedOn, Processing, Ref_Invoice_ID, Reversal_ID, SendEMail, User1_ID, User2_ID, C_PaymentTerm_AD_Org_ID, AfterDelivery, C_PaymentTerm_ID, c_paymentterm_description, Discount, Discount2, DiscountDays, DiscountDays2, FixMonthCutoff, FixMonthDay, FixMonthOffset, GraceDays, c_paymentterm_isactive, IsDefault, IsDueFixed, IsNextBusinessDay, IsValid, NetDay, NetDays, PaymentTermUsage, c_paymentterm_value, bp_acqusitioncost, bp_actuallifetimevalue, bp_ad_language, BP_AD_OrgBP_ID, BP_AD_Org_ID, BP_BPartner_Parent_ID, BP_C_BP_Group_ID, BP_C_Dunning_ID, BP_C_Greeting_ID, BP_C_InvoiceSchedule_ID, BP_C_PaymentTerm_ID, bp_created, BP_CreatedBy, BP_C_TaxGroup_ID, bp_deliveryrule, bp_deliveryviarule, bp_description, bp_dunninggrace, bp_firstsale, bp_flatdiscount, bp_freightcostrule, bp_invoicerule, bp_isactive, bp_iscustomer, bp_isdiscountprinted, bp_isemployee, bp_ismanufacturer, bp_isonetime, bp_ispotaxexempt, bp_isprospect, bp_issalesrep, bp_issummary, bp_istaxexempt, bp_isvendor, BP_Logo_ID, BP_M_DiscountSchema_ID, BP_M_PriceList_ID, bp_naics, bp_numberemployees, bp_paymentrule, bp_paymentrulepo, BP_PO_DiscountSchema_ID, BP_PO_PaymentTerm_ID, BP_PO_PriceList_ID, bp_poreference, bp_potentiallifetimevalue, bp_rating, BP_SalesRep_ID, bp_salesvolume, bp_sendemail, bp_shareofcustomer, bp_shelflifeminpct, bp_so_creditlimit, bp_socreditstatus, bp_so_creditused, bp_so_description, bp_totalopenbalance, bp_updated, BP_UpdatedBy, bp_url, c_greeting_isactive, IsFirstNameOnly, c_greeting_name, BP_Location_AD_Org_ID, BP_Location_C_BPartner_ID, bp_location_created, BP_Location_CreatedBy, C_SalesRegion_ID, bp_location_fax, bp_location_isactive, IsBillTo, ISDN, IsPayFrom, IsRemitTo, IsShipTo, bp_location_name, bp_location_phone, bp_location_phone2, bp_location_updated, BP_Location_UpdatedBy, Address1, Address2, Address3, Address4, C_Location_AD_Org_ID, C_City_ID, C_Country_ID, City, c_location_created, C_Location_CreatedBy, C_Region_ID, c_location_isactive, RegionName, c_location_updated, C_Location_UpdatedBy, AD_User_AD_Org_ID, AD_User_AD_AD_OrgTrx_ID, ad_user_ad_birthday, AD_User_C_BPartner_ID, AD_User_C_BPartner_Location_ID, AD_User_C_Greeting_ID, ad_user_comments, ad_user_created, AD_User_CreatedBy, ad_user_description, ad_user_email, ad_user_fax, ad_user_isactive, ad_user_lastcontact, ad_user_lastresult, ad_user_phone2, AD_User_Supervisor_ID, ad_user_updated, AD_User_UpdatedBy, ad_user_value, user_greeting_isactive, user_greeting_isfirstnameonly, user_greeting_name, AD_OrgInfo_AD_Org_ID, AD_OrgType_ID, C_Calendar_ID, ad_orginfo_created, AD_OrgInfo_CreatedBy, DropShip_Warehouse_ID, ad_orginfo_duns, ad_orginfo_email, ad_orginfo_fax, ad_orginfo_isactive, M_Warehouse_ID, Parent_Org_ID, ad_orginfo_phone, ad_orginfo_phone2, ReceiptFooterMsg, Supervisor_ID, ad_orginfo_updated, AD_OrgInfo_UpdatedBy, SalesRep_AD_Org_ID, SalesRep_AD_AD_OrgTrx_ID, salesrep_ad_birthday, SalesRep_C_BPartner_ID, SalesRep_C_BP_Location_ID, SalesRep_C_Greeting_ID, salesrep_comments, salesrep_created, SalesRep_CreatedBy, salesrep_descriptio
;
-- Nov 28, 2021, 11:19:15 PM CET
CREATE OR REPLACE VIEW RV_Cash_Detail(C_Cash_ID, C_CashLine_ID, AD_Client_ID, AD_Org_ID, IsActive, Created, CreatedBy, Updated, UpdatedBy, C_CashBook_ID, Name, StatementDate, DateAcct, Processed, Posted, Line, Description, CashType, C_Currency_ID, Amount, ConvertedAmt, C_BankAccount_ID, C_Invoice_ID, C_Charge_ID) AS SELECT cl.c_cash_id AS C_Cash_ID, cl.c_cashline_id AS C_CashLine_ID, c.ad_client_id AS AD_Client_ID, c.ad_org_id AS AD_Org_ID, cl.isactive AS IsActive, cl.created AS Created, cl.createdby AS CreatedBy, cl.updated AS Updated, cl.updatedby AS UpdatedBy, c.c_cashbook_id AS C_CashBook_ID, c.name AS Name, c.statementdate AS StatementDate, c.dateacct AS DateAcct, c.processed AS Processed, c.posted AS Posted, cl.line AS Line, cl.description AS Description, cl.cashtype AS CashType, cl.c_currency_id AS C_Currency_ID, cl.amount AS Amount, currencyconvert(cl.amount, cl.c_currency_id, cb.c_currency_id, c.statementdate, 0, c.ad_client_id, c.ad_org_id) AS ConvertedAmt, cl.c_bankaccount_id AS C_BankAccount_ID, cl.c_invoice_id AS C_Invoice_ID, cl.c_charge_id AS C_Charge_ID FROM c_cash c JOIN c_cashline cl ON c.c_cash_id = cl.c_cash_id JOIN c_cashbook cb ON c.c_cashbook_id = cb.c_cashbook_id
;
-- Nov 28, 2021, 11:19:15 PM CET
CREATE OR REPLACE VIEW RV_WarehousePrice(AD_Client_ID, AD_Org_ID, IsActive, Created, CreatedBy, Updated, UpdatedBy, M_Product_ID, M_PriceList_Version_ID, M_Warehouse_ID, Value, Name, UPC, SKU, C_UOM_ID, UOMSymbol, PriceList, PriceStd, Margin, PriceLimit, WarehouseName, QtyAvailable, QtyOnHand, QtyReserved, QtyOrdered, IsInstanceAttribute) AS SELECT w.ad_client_id AS AD_Client_ID, w.ad_org_id AS AD_Org_ID, CASE WHEN p.discontinued = 'N' THEN 'Y' ELSE 'N' END AS IsActive, pr.created AS Created, pr.createdby AS CreatedBy, pr.updated AS Updated, pr.updatedby AS UpdatedBy, p.m_product_id AS M_Product_ID, pr.m_pricelist_version_id AS M_PriceList_Version_ID, w.m_warehouse_id AS M_Warehouse_ID, p.value AS Value, p.name AS Name, p.upc AS UPC, p.sku AS SKU, uom.c_uom_id AS C_UOM_ID, uom.uomsymbol AS UOMSymbol, bompricelist(p.m_product_id, pr.m_pricelist_version_id) AS PriceList, bompricestd(p.m_product_id, pr.m_pricelist_version_id) AS PriceStd, bompricestd(p.m_product_id, pr.m_pricelist_version_id) - bompricelimit(p.m_product_id, pr.m_pricelist_version_id) AS Margin, bompricelimit(p.m_product_id, pr.m_pricelist_version_id) AS PriceLimit, w.name AS WarehouseName, bomqtyavailable(p.m_product_id, w.m_warehouse_id, 0) AS QtyAvailable, bomqtyonhand(p.m_product_id, w.m_warehouse_id, 0) AS QtyOnHand, bomqtyreserved(p.m_product_id, w.m_warehouse_id, 0) AS QtyReserved, bomqtyordered(p.m_product_id, w.m_warehouse_id, 0) AS QtyOrdered, COALESCE(pa.isinstanceattribute, 'N') AS IsInstanceAttribute FROM m_product p JOIN m_productprice pr ON p.m_product_id = pr.m_product_id JOIN c_uom uom ON p.c_uom_id = uom.c_uom_id LEFT JOIN m_attributeset pa ON p.m_attributeset_id = pa.m_attributeset_id JOIN m_warehouse w ON p.ad_client_id = w.ad_client_id WHERE p.issummary = 'N' AND p.isactive = 'Y' AND pr.isactive = 'Y' AND w.isactive = 'Y'
;
-- Nov 28, 2021, 11:19:15 PM CET
CREATE OR REPLACE VIEW RV_Fact_Acct_Day(AD_Client_ID, AD_Org_ID, C_AcctSchema_ID, Account_ID, DateAcct, C_Period_ID, GL_Category_ID, GL_Budget_ID, C_Tax_ID, M_Locator_ID, PostingType, C_Currency_ID, AmtSourceDr, AmtSourceCr, AmtSource, AmtAcctDr, AmtAcctCr, AmtAcct, Rate, M_Product_ID, C_BPartner_ID, AD_OrgTrx_ID, C_LocFrom_ID, C_LocTo_ID, C_SalesRegion_ID, C_Project_ID, C_Campaign_ID, C_Activity_ID, User1_ID, User2_ID, A_Asset_ID) AS SELECT fact_acct.ad_client_id AS AD_Client_ID, fact_acct.ad_org_id AS AD_Org_ID, fact_acct.c_acctschema_id AS C_AcctSchema_ID, fact_acct.account_id AS Account_ID, firstof(fact_acct.dateacct, 'DD') AS DateAcct, fact_acct.c_period_id AS C_Period_ID, fact_acct.gl_category_id AS GL_Category_ID, fact_acct.gl_budget_id AS GL_Budget_ID, fact_acct.c_tax_id AS C_Tax_ID, fact_acct.m_locator_id AS M_Locator_ID, fact_acct.postingtype AS PostingType, fact_acct.c_currency_id AS C_Currency_ID, sum(fact_acct.amtsourcedr) AS AmtSourceDr, sum(fact_acct.amtsourcecr) AS AmtSourceCr, sum(fact_acct.amtsourcedr - fact_acct.amtsourcecr) AS AmtSource, sum(fact_acct.amtacctdr) AS AmtAcctDr, sum(fact_acct.amtacctcr) AS AmtAcctCr, sum(fact_acct.amtacctdr - fact_acct.amtacctcr) AS AmtAcct, CASE WHEN sum(fact_acct.amtsourcedr - fact_acct.amtsourcecr) = 0 THEN 0 ELSE sum(fact_acct.amtacctdr - fact_acct.amtacctcr) / sum(fact_acct.amtsourcedr - fact_acct.amtsourcecr) END AS Rate, fact_acct.m_product_id AS M_Product_ID, fact_acct.c_bpartner_id AS C_BPartner_ID, fact_acct.ad_orgtrx_id AS AD_OrgTrx_ID, fact_acct.c_locfrom_id AS C_LocFrom_ID, fact_acct.c_locto_id AS C_LocTo_ID, fact_acct.c_salesregion_id AS C_SalesRegion_ID, fact_acct.c_project_id AS C_Project_ID, fact_acct.c_campaign_id AS C_Campaign_ID, fact_acct.c_activity_id AS C_Activity_ID, fact_acct.user1_id AS User1_ID, fact_acct.user2_id AS User2_ID, fact_acct.a_asset_id AS A_Asset_ID FROM fact_acct GROUP BY fact_acct.ad_client_id, fact_acct.ad_org_id, fact_acct.c_acctschema_id, fact_acct.account_id, (firstof(fact_acct.dateacct, 'DD')), fact_acct.c_period_id, fact_acct.gl_category_id, fact_acct.gl_budget_id, fact_acct.c_tax_id, fact_acct.m_locator_id, fact_acct.postingtype, fact_acct.c_currency_id, fact_acct.m_product_id, fact_acct.c_bpartner_id, fact_acct.ad_orgtrx_id, fact_acct.c_locfrom_id, fact_acct.c_locto_id, fact_acct.c_salesregion_id, fact_acct.c_project_id, fact_acct.c_campaign_id, fact_acct.c_activity_id, fact_acct.user1_id, fact_acct.user2_id, fact_acct.a_asset_id
;
-- Nov 28, 2021, 11:19:15 PM CET
CREATE OR REPLACE VIEW RV_Fact_Acct(AD_Client_ID, AD_Org_ID, IsActive, Created, CreatedBy, Updated, UpdatedBy, Fact_Acct_ID, C_AcctSchema_ID, Account_ID, DateTrx, DateAcct, C_Period_ID, AD_Table_ID, Record_ID, Line_ID, GL_Category_ID, GL_Budget_ID, C_Tax_ID, M_Locator_ID, PostingType, C_Currency_ID, AmtSourceDr, AmtSourceCr, AmtSource, AmtAcctDr, AmtAcctCr, AmtAcct, Rate, C_UOM_ID, Qty, M_Product_ID, C_BPartner_ID, AD_OrgTrx_ID, C_LocFrom_ID, C_LocTo_ID, C_SalesRegion_ID, C_Project_ID, C_Campaign_ID, C_Activity_ID, User1_ID, User2_ID, A_Asset_ID, Description, OrgValue, OrgName, AccountValue, Name, AccountType, BPartnerValue, BPName, C_BP_Group_ID, ProductValue, ProductName, UPC, M_Product_Category_ID, C_ProjectPhase_ID, C_ProjectTask_ID, C_SubAcct_ID, UserElement1_ID, UserElement2_ID, ad_org_description, ad_org_isactive, C_ElementValue_AD_Org_ID, C_BankAccount_ID, C_ElementValue_C_Currency_ID, C_Element_ID, C_ElementValue_ID, c_elementvalue_description, c_elementvalue_isactive, IsBankAccount, IsForeignCurrency, c_elementvalue_issummary, c_bp_acqusitioncost, c_bp_actuallifetimevalue, c_bp_ad_language, C_BP_AD_OrgBP_ID, C_BP_AD_Org_ID, C_BP_BPartner_Parent_ID, C_BP_C_Dunning_ID, C_BP_C_Greeting_ID, C_BP_C_InvoiceSchedule_ID, C_BP_C_PaymentTerm_ID, c_bp_created, C_BP_CreatedBy, C_BP_C_TaxGroup_ID, c_bp_deliveryrule, c_bp_deliveryviarule, c_bp_description, c_bp_dunninggrace, DUNS, c_bp_firstsale, c_bp_flatdiscount, c_bp_freightcostrule, c_bp_invoicerule, c_bp_isactive, c_bp_iscustomer, c_bp_isdiscountprinted, c_bp_isemployee, c_bp_ismanufacturer, c_bp_isonetime, c_bp_ispotaxexempt, c_bp_isprospect, c_bp_issalesrep, c_bp_issummary, c_bp_istaxexempt, c_bp_isvendor, C_BP_Logo_ID, C_BP_M_DiscountSchema_ID, C_BP_M_PriceList_ID, NAICS, c_bp_name2, c_bp_numberemployees, c_bp_paymentrule, c_bp_paymentrulepo, C_BP_PO_DiscountSchema_ID, C_BP_PO_PaymentTerm_ID, C_BP_PO_PriceList_ID, c_bp_poreference, c_bp_potentiallifetimevalue, c_bp_rating, ReferenceNo, C_BP_SalesRep_ID, c_bp_salesvolume, c_bp_sendemail, c_bp_shareofcustomer, c_bp_shelflifeminpct, c_bp_so_creditlimit, c_bp_socreditstatus, c_bp_so_creditused, c_bp_so_description, TaxID, c_bp_totalopenbalance, c_bp_updated, C_BP_UpdatedBy, c_bp_url, 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, m_product_description, DescriptionURL, Discontinued, DiscontinuedAt, DocumentNote, Group1, Group2, GuaranteeDays, GuaranteeDaysMin, Help, ImageURL, m_product_isactive, IsDropShip, IsExcludeAutoDelivery, IsInvoicePrintDetails, IsPickListPrintDetails, IsPurchased, IsSelfService, IsSold, IsStocked, m_product_issummary, IsVerified, IsWebStoreFeatured, LowLevel, M_Product_M_AttributeSet_ID, M_Product_M_ASI_ID, M_FreightCategory_ID, M_Product_M_Locator_ID, m_product_processing, ProductType, R_MailText_ID, M_Product_SalesRep_ID, S_ExpenseType_ID, ShelfDepth, ShelfHeight, ShelfWidth, SKU, S_Resource_ID, UnitsPerPack, UnitsPerPallet, m_product_updated, M_Product_UpdatedBy, VersionNo, Volume, Weight) AS SELECT f.ad_client_id AS AD_Client_ID, f.ad_org_id AS AD_Org_ID, f.isactive AS IsActive, f.created AS Created, f.createdby AS CreatedBy, f.updated AS Updated, f.updatedby AS UpdatedBy, f.fact_acct_id AS Fact_Acct_ID, f.c_acctschema_id AS C_AcctSchema_ID, f.account_id AS Account_ID, f.datetrx AS DateTrx, f.dateacct AS DateAcct, f.c_period_id AS C_Period_ID, f.ad_table_id AS AD_Table_ID, f.record_id AS Record_ID, f.line_id AS Line_ID, f.gl_category_id AS GL_Category_ID, f.gl_budget_id AS GL_Budget_ID, f.c_tax_id AS C_Tax_ID, f.m_locator_id AS M_Locator_ID, f.postingtype AS PostingType, f.c_currency_id AS C_Currency_ID, f.amtsourcedr AS AmtSourceDr, f.amtsourcecr AS AmtSourceCr, f.amtsourcedr - f.amtsourcecr AS AmtSource, f.amtacctdr AS AmtAcctDr, f.amtacctcr AS AmtAcctCr, f.amtacctdr - f.amtacctcr AS AmtAcct, CASE WHEN (f.amtsourcedr - f.amtsourcecr) = 0 THEN 0 ELSE (f.amtacctdr - f.amtacctcr) / (f.amtsourcedr - f.amtsourcecr) END AS Rate, f.c_uom_id AS C_UOM_ID, f.qty AS Q
;
-- Nov 28, 2021, 11:19:15 PM CET
CREATE OR REPLACE VIEW C_PaySelection_Check_v(AD_Client_ID, AD_Org_ID, AD_Language, C_PaySelection_ID, C_PaySelectionCheck_ID, Org_Location_ID, TaxID, C_DocType_ID, C_BPartner_ID, BPValue, BPTaxID, NAICS, DUNS, BPGreeting, Name, Name2, C_Location_ID, ReferenceNo, POReference, PayDate, PayAmt, AmtInWords, Qty, PaymentRule, DocumentNo, Logo_ID, DocumentType, DocumentTypeNote, Description, BankAccountDescription, C_BP_BankAccount_ID, C_Payment_ID, c_payselectioncheck_created, C_PaySelectionCheck_CreatedBy, c_payselectioncheck_discamt, c_payselectioncheck_isactive, IsGeneratedDraft, IsPrinted, IsReceipt, Processed, c_payselectioncheck_updated, C_PaySelectionCheck_UpdatedBy, C_PaySelection_AD_Org_ID, C_PaySel_C_BankAccount_ID, c_payselection_created, C_PaySelection_CreatedBy, c_payselection_description, c_payselection_isactive, c_payselection_isapproved, c_payselection_name, c_payselection_processed, TotalAmt, c_payselection_updated, C_PaySelection_UpdatedBy, A_City, A_Country, C_Payment_AD_Org_ID, A_EMail, A_Ident_DL, A_Name, A_State, A_Street, A_Zip, C_Activity_ID, C_Payment_C_BPartner_ID, C_Campaign_ID, C_Payment_C_Charge_ID, C_ConversionType_ID, C_Currency_ID, c_payment_chargeamt, CheckNo, C_Payment_C_Invoice_ID, C_Payment_C_Order_ID, C_PaymentBatch_ID, C_Project_ID, c_payment_created, C_Payment_CreatedBy, DateAcct, DateTrx, c_payment_discountamt, DocStatus, c_payment_documentno, c_payment_isactive, IsAllocated, IsApproved, IsDelayedCapture, IsOnline, IsOverUnderPayment, IsPrepayment, IsReconciled, c_payment_isselfservice, Micr, Orig_TrxID, OverUnderAmt, c_payment_payamt, PONum, c_payment_posted, c_payment_processed, c_payment_processedon, R_AuthCode, R_AuthCode_DC, R_AvsAddr, R_AvsZip, R_CVV2Match, Ref_Payment_ID, C_Payment_Reversal_ID, R_Info, RoutingNo, R_PnRef, R_PnRef_DC, R_RespMsg, R_Result, Swipe, TaxAmt, TenderType, TrxType, c_payment_updated, C_Payment_UpdatedBy, User1_ID, User2_ID, VoiceAuthCode, WriteOffAmt, c_bp_acqusitioncost, c_bp_actuallifetimevalue, c_bp_ad_language, C_BP_AD_OrgBP_ID, C_BP_AD_Org_ID, C_BP_BPartner_Parent_ID, C_BP_C_BP_Group_ID, C_BP_C_Dunning_ID, C_BP_C_Greeting_ID, C_BP_C_InvoiceSchedule_ID, C_BP_C_PaymentTerm_ID, c_bp_created, C_BP_CreatedBy, C_BP_C_TaxGroup_ID, c_bp_deliveryrule, c_bp_deliveryviarule, c_bp_description, c_bp_dunninggrace, c_bp_firstsale, c_bp_flatdiscount, c_bp_freightcostrule, c_bp_invoicerule, c_bp_isactive, c_bp_iscustomer, c_bp_isdiscountprinted, c_bp_isemployee, c_bp_ismanufacturer, c_bp_isonetime, c_bp_ispotaxexempt, c_bp_isprospect, c_bp_issalesrep, c_bp_issummary, c_bp_istaxexempt, c_bp_isvendor, C_BP_Logo_ID, C_BP_M_DiscountSchema_ID, C_BP_M_PriceList_ID, c_bp_numberemployees, c_bp_paymentrule, c_bp_paymentrulepo, C_BP_PO_DiscountSchema_ID, C_BP_PO_PaymentTerm_ID, C_BP_PO_PriceList_ID, c_bp_potentiallifetimevalue, c_bp_rating, C_BP_SalesRep_ID, c_bp_salesvolume, c_bp_sendemail, c_bp_shareofcustomer, c_bp_shelflifeminpct, c_bp_so_creditlimit, c_bp_socreditstatus, c_bp_so_creditused, c_bp_so_description, c_bp_totalopenbalance, c_bp_updated, C_BP_UpdatedBy, c_bp_url, C_Greeting_AD_Org_ID, c_greeting_isactive, IsFirstNameOnly, c_greeting_name, AD_OrgInfo_AD_Org_ID, AD_OrgType_ID, C_Calendar_ID, ad_orginfo_created, AD_OrgInfo_CreatedBy, DropShip_Warehouse_ID, ad_orginfo_duns, ad_orginfo_email, ad_orginfo_fax, ad_orginfo_isactive, M_Warehouse_ID, Parent_Org_ID, ad_orginfo_phone, ad_orginfo_phone2, ReceiptFooterMsg, Supervisor_ID, ad_orginfo_updated, AD_OrgInfo_UpdatedBy) AS SELECT psc.ad_client_id AS AD_Client_ID, psc.ad_org_id AS AD_Org_ID, CAST('en_US' AS CHARACTER VARYING(6)) AS AD_Language, psc.c_payselection_id AS C_PaySelection_ID, psc.c_payselectioncheck_id AS C_PaySelectionCheck_ID, oi.c_location_id AS Org_Location_ID, oi.taxid AS TaxID, p.c_doctype_id AS C_DocType_ID, bp.c_bpartner_id AS C_BPartner_ID, bp.value AS BPValue, bp.taxid AS BPTaxID, bp.naics AS NAICS, bp.duns AS DUNS, bpg.greeting AS BPGreeting, bp.name AS Name, bp.name2 AS Name2, bpartnerremitlocation(bp.c_bpartner_id) AS C_Location_ID, bp.referenceno AS ReferenceNo, bp.poreference AS POReference
;
-- Nov 28, 2021, 11:19:15 PM CET
CREATE OR REPLACE VIEW M_InOut_Line_v(AD_Client_ID, AD_Org_ID, IsActive, Created, CreatedBy, Updated, UpdatedBy, AD_Language, M_InOut_ID, M_InOutLine_ID, Line, M_Product_ID, MovementQty, QtyEntered, UOMSymbol, QtyOrdered, QtyDelivered, QtyBackOrdered, Name, Description, DocumentNote, UPC, SKU, ProductValue, M_Locator_ID, M_Warehouse_ID, X, Y, Z, M_AttributeSetInstance_ID, M_AttributeSet_ID, SerNo, Lot, M_Lot_ID, GuaranteeDate, ProductDescription, ImageURL, C_Campaign_ID, C_Project_ID, C_Activity_ID, C_ProjectPhase_ID, C_ProjectTask_ID, AD_OrgTrx_ID, C_Charge_ID, ConfirmedQty, C_OrderLine_ID, M_InOutLine_C_UOM_ID, m_inoutline_isdescription, IsInvoiced, M_RMALine_ID, PickedQty, m_inoutline_processed, Ref_InOutLine_ID, ReversalLine_ID, ScrappedQty, TargetQty, M_InOutLine_User1_ID, M_InOutLine_User2_ID, M_Product_AD_Org_ID, Classification, m_product_copyfrom, m_product_created, M_Product_CreatedBy, C_RevenueRecognition_ID, C_SubscriptionType_ID, M_Product_C_TaxCategory_ID, M_Product_C_UOM_ID, DescriptionURL, Discontinued, DiscontinuedAt, Group1, Group2, GuaranteeDays, GuaranteeDaysMin, Help, m_product_isactive, IsBOM, IsDropShip, IsExcludeAutoDelivery, IsInvoicePrintDetails, IsPickListPrintDetails, IsPurchased, m_product_isselfservice, IsSold, IsStocked, m_product_issummary, IsVerified, IsWebStoreFeatured, LowLevel, M_Product_M_AttributeSet_ID, M_Product_M_ASI_ID, M_FreightCategory_ID, M_Product_M_Locator_ID, M_Product_M_Prod_Category_ID, m_product_processing, ProductType, R_MailText_ID, M_Product_SalesRep_ID, S_ExpenseType_ID, ShelfDepth, ShelfHeight, ShelfWidth, M_Product_S_Resource_ID, UnitsPerPack, UnitsPerPallet, m_product_updated, M_Product_UpdatedBy, VersionNo, Volume, Weight, C_UOM_AD_Org_ID, CostingPrecision, c_uom_description, c_uom_isactive, c_uom_isdefault, c_uom_name, StdPrecision, UOMType, X12DE355, M_ASI_AD_Org_ID, m_asi_created, M_ASI_CreatedBy, M_ASI_Description, m_asi_isactive, m_asi_updated, M_ASI_UpdatedBy, M_Locator_AD_Org_ID, m_locator_isactive, IsDefault, PriorityNo, m_locator_value, C_OrderLine_AD_Org_ID, C_OrderLine_AD_OrgTrx_ID, C_OrderLine_C_Activity_ID, C_OrderLine_C_BPartner_ID, C_OrderLine_C_BP_Location_ID, C_OrderLine_C_Charge_ID, C_OrderLine_C_Currency_ID, C_Order_ID, C_OrderLine_C_Project_ID, C_OrderLine_C_ProjectPhase_ID, C_OrderLine_C_ProjectTask_ID, c_orderline_created, C_OrderLine_CreatedBy, C_OrderLine_C_Tax_ID, C_OrderLine_C_UOM_ID, DateDelivered, DateInvoiced, DateOrdered, c_orderline_datepromised, c_orderline_description, Discount, c_orderline_freightamt, c_orderline_isactive, c_orderline_isdescription, c_orderline_line, LineNetAmt, Link_OrderLine_ID, C_OrderLine_M_ASI_ID, C_OrderLine_M_Product_ID, M_Promotion_ID, C_OrderLine_M_Shipper_ID, C_OrderLine_Warehouse_ID, PriceActual, PriceCost, PriceEntered, PriceLimit, PriceList, c_orderline_processed, c_orderline_qtyentered, QtyInvoiced, QtyLostSales, QtyReserved, Ref_OrderLine_ID, RRAmt, RRStartDate, S_ResourceAssignment_ID, c_orderline_updated, C_OrderLine_UpdatedBy, C_OrderLine_User1_ID, C_OrderLine_User2_ID, 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) AS SELECT iol.ad_client_id AS AD_Client_ID, iol.ad_org_id AS AD_Org_ID, iol.isactive AS IsActive, iol.created AS Created, iol.createdby AS CreatedBy, iol.updated AS Updated, iol.updatedby AS UpdatedBy, CAST('en_US' AS CHARACTER VARYING(6)) AS AD_Language, iol.m_inout_id AS M_InOut_ID, iol.m_inoutline_id AS M_InOutLine_ID, iol.line AS Line, p.m_product_id AS M_Product_ID, CASE WHEN iol.movementqty <> 0 OR iol.m_product_id IS NOT NULL THEN iol.movementqty ELSE NULL END AS MovementQty, CASE WHEN iol.qtyentered <> 0 OR iol.m_product_id IS NOT NULL THEN iol.qtyentered ELSE NULL END AS QtyEntered, CASE WHEN iol.movementqty <> 0 OR iol.m_product_id IS NOT NULL THEN uom.uomsymbol ELSE NULL END AS UOMSymbol, ol.qtyordered AS QtyOrdered, ol.qtydelivered AS QtyDelivered, CASE WHEN iol.movementqty <> 0 OR iol.m_product_id IS NOT NULL THEN ol.qtyo
;
-- Nov 28, 2021, 11:19:15 PM CET
CREATE OR REPLACE VIEW RV_BPartner(AD_Client_ID, AD_Org_ID, IsActive, Created, CreatedBy, Updated, UpdatedBy, C_BPartner_ID, Value, Name, Name2, Description, IsSummary, C_BP_Group_ID, IsOneTime, IsProspect, IsVendor, IsCustomer, IsEmployee, IsSalesRep, ReferenceNo, DUNS, URL, AD_Language, TaxID, IsTaxExempt, C_InvoiceSchedule_ID, Rating, SalesVolume, NumberEmployees, NAICS, FirstSale, AcqusitionCost, PotentialLifeTimeValue, ActualLifeTimeValue, ShareOfCustomer, PaymentRule, SO_CreditLimit, SO_CreditUsed, SO_CreditAvailable, C_PaymentTerm_ID, M_PriceList_ID, M_DiscountSchema_ID, C_Dunning_ID, IsDiscountPrinted, SO_Description, POReference, PaymentRulePO, PO_PriceList_ID, PO_DiscountSchema_ID, PO_PaymentTerm_ID, DocumentCopies, C_Greeting_ID, InvoiceRule, DeliveryRule, FreightCostRule, DeliveryViaRule, SalesRep_ID, SendEMail, BPartner_Parent_ID, Invoice_PrintFormat_ID, SOCreditStatus, ShelfLifeMinPct, AD_OrgBP_ID, FlatDiscount, TotalOpenBalance, AD_User_ID, ContactName, ContactDescription, EMail, Supervisor_ID, EMailUser, BPContactGreeting, Title, Comments, Phone, Phone2, Fax, LastContact, LastResult, Birthday, AD_OrgTrx_ID, EMailVerify, LDAPUser, EMailVerifyDate, NotificationType, C_BPartner_Location_ID, Postal, City, Address1, Address2, Address3, C_Region_ID, RegionName, C_Country_ID, CountryName, C_BP_C_TaxGroup_ID, c_bp_dunninggrace, c_bp_ismanufacturer, c_bp_ispotaxexempt, C_BP_Logo_ID, C_BP_Location_AD_Org_ID, C_BP_Location_C_BPartner_ID, C_BP_Location_C_Location_ID, c_bp_location_created, C_BP_Location_CreatedBy, C_BP_Location_SalesRegion_ID, c_bp_location_fax, c_bp_location_isactive, c_bp_location_isbillto, c_bp_location_isdn, c_bp_location_ispayfrom, c_bp_location_isremitto, c_bp_location_isshipto, c_bp_location_name, c_bp_location_phone, c_bp_location_phone2, c_bp_location_updated, C_BP_Location_UpdatedBy, AD_User_AD_Org_ID, AD_User_C_BPartner_ID, AD_User_C_BPartner_Location_ID, ad_user_created, AD_User_CreatedBy, ad_user_isactive, ad_user_updated, AD_User_UpdatedBy, ad_user_value, Address4, C_Location_AD_Org_ID, C_City_ID, C_Location_ID, c_location_created, C_Location_CreatedBy, c_location_isactive, Postal_Add, c_location_updated, C_Location_UpdatedBy, C_Region_AD_Org_ID, C_Region_C_Country_ID, c_region_description, c_region_isactive, IsDefault, c_country_ad_language, C_Country_C_Currency_ID, CountryCode, c_country_description, c_country_isactive) AS SELECT bp.ad_client_id AS AD_Client_ID, bp.ad_org_id AS AD_Org_ID, bp.isactive AS IsActive, bp.created AS Created, bp.createdby AS CreatedBy, bp.updated AS Updated, bp.updatedby AS UpdatedBy, bp.c_bpartner_id AS C_BPartner_ID, bp.value AS Value, bp.name AS Name, bp.name2 AS Name2, bp.description AS Description, bp.issummary AS IsSummary, bp.c_bp_group_id AS C_BP_Group_ID, bp.isonetime AS IsOneTime, bp.isprospect AS IsProspect, bp.isvendor AS IsVendor, bp.iscustomer AS IsCustomer, bp.isemployee AS IsEmployee, bp.issalesrep AS IsSalesRep, bp.referenceno AS ReferenceNo, bp.duns AS DUNS, bp.url AS URL, bp.ad_language AS AD_Language, bp.taxid AS TaxID, bp.istaxexempt AS IsTaxExempt, bp.c_invoiceschedule_id AS C_InvoiceSchedule_ID, bp.rating AS Rating, bp.salesvolume AS SalesVolume, bp.numberemployees AS NumberEmployees, bp.naics AS NAICS, bp.firstsale AS FirstSale, bp.acqusitioncost AS AcqusitionCost, bp.potentiallifetimevalue AS PotentialLifeTimeValue, bp.actuallifetimevalue AS ActualLifeTimeValue, bp.shareofcustomer AS ShareOfCustomer, bp.paymentrule AS PaymentRule, bp.so_creditlimit AS SO_CreditLimit, bp.so_creditused AS SO_CreditUsed, bp.so_creditused - bp.so_creditlimit AS SO_CreditAvailable, bp.c_paymentterm_id AS C_PaymentTerm_ID, bp.m_pricelist_id AS M_PriceList_ID, bp.m_discountschema_id AS M_DiscountSchema_ID, bp.c_dunning_id AS C_Dunning_ID, bp.isdiscountprinted AS IsDiscountPrinted, bp.so_description AS SO_Description, bp.poreference AS POReference, bp.paymentrulepo AS PaymentRulePO, bp.po_pricelist_id AS PO_PriceList_ID, bp.po_discountschema_id AS PO_DiscountSchema_ID, bp.po_paymentterm_id AS PO_PaymentTerm_ID, bp.documentcopies AS DocumentCopies, bp.c_gree
;
-- Nov 28, 2021, 11:19:15 PM CET
CREATE OR REPLACE VIEW C_Dunning_Line_v(AD_Client_ID, AD_Org_ID, IsActive, Created, CreatedBy, Updated, UpdatedBy, AD_Language, C_DunningRunLine_ID, C_DunningRunEntry_ID, Amt, ConvertedAmt, DaysDue, TimesDunned, InterestAmt, FeeAmt, TotalAmt, C_Invoice_ID, IsSOTrx, DocumentNo, DocStatus, DateTrx, C_DocType_ID, DocumentType, Description, C_Currency_ID, C_Campaign_ID, C_Project_ID, C_Activity_ID, User1_ID, User2_ID, DateAcct, C_ConversionType_ID, AD_OrgTrx_ID, POReference, DateOrdered, DateInvoiced, IsInDispute, PaymentTerm, C_Charge_ID, ChargeAmt, TotalLines, GrandTotal, AmtInWords, M_PriceList_ID, IsPaid, IsAllocated, TenderType, DiscountAmt, C_InvoicePaySchedule_ID, C_Payment_ID, c_dunningrunline_isindispute, OpenAmt, c_dunningrunline_processed, C_Invoice_AD_Org_ID, AD_User_ID, C_Invoice_C_BPartner_ID, C_BPartner_Location_ID, C_DocTypeTarget_ID, C_DunningLevel_ID, C_Invoice_C_Order_ID, C_Invoice_C_Payment_ID, c_invoice_created, C_Invoice_CreatedBy, DatePrinted, DocAction, DunningGrace, GenerateTo, InvoiceCollectionType, c_invoice_isactive, c_invoice_isapproved, IsDiscountPrinted, IsPayScheduleValid, IsPrinted, c_invoice_isselfservice, IsTaxIncluded, IsTransferred, M_RMA_ID, PaymentRule, c_invoice_posted, c_invoice_processedon, Processing, Ref_Invoice_ID, C_Invoice_Reversal_ID, SalesRep_ID, SendEMail, c_invoice_updated, C_Invoice_UpdatedBy, C_PaymentTerm_AD_Org_ID, AfterDelivery, C_PaymentTerm_ID, c_paymentterm_description, Discount, Discount2, DiscountDays, DiscountDays2, DocumentNote, FixMonthCutoff, FixMonthDay, FixMonthOffset, GraceDays, c_paymentterm_isactive, IsDueFixed, IsNextBusinessDay, IsValid, NetDay, NetDays, PaymentTermUsage, c_paymentterm_value, A_City, A_Country, C_Payment_AD_Org_ID, A_EMail, A_Ident_DL, A_Name, A_State, A_Street, A_Zip, C_Payment_C_BPartner_ID, C_Payment_C_Charge_ID, c_payment_chargeamt, CheckNo, C_Payment_C_Invoice_ID, C_Payment_C_Order_ID, C_PaymentBatch_ID, c_payment_created, C_Payment_CreatedBy, c_payment_isactive, IsApproved, IsDelayedCapture, IsOnline, IsOverUnderPayment, IsPrepayment, IsReconciled, c_payment_isselfservice, Micr, Orig_TrxID, OverUnderAmt, PayAmt, PONum, c_payment_posted, c_payment_processed, c_payment_processedon, R_AuthCode, R_AuthCode_DC, R_AvsAddr, R_AvsZip, R_CVV2Match, Ref_Payment_ID, C_Payment_Reversal_ID, R_Info, RoutingNo, R_PnRef, R_PnRef_DC, R_RespMsg, R_Result, Swipe, TaxAmt, TrxType, c_payment_updated, C_Payment_UpdatedBy, VoiceAuthCode, WriteOffAmt) AS SELECT drl.ad_client_id AS AD_Client_ID, drl.ad_org_id AS AD_Org_ID, drl.isactive AS IsActive, drl.created AS Created, drl.createdby AS CreatedBy, drl.updated AS Updated, drl.updatedby AS UpdatedBy, CAST('en_US' AS CHARACTER VARYING(6)) AS AD_Language, drl.c_dunningrunline_id AS C_DunningRunLine_ID, drl.c_dunningrunentry_id AS C_DunningRunEntry_ID, drl.amt AS Amt, drl.convertedamt AS ConvertedAmt, drl.daysdue AS DaysDue, drl.timesdunned AS TimesDunned, drl.interestamt AS InterestAmt, drl.feeamt AS FeeAmt, drl.totalamt AS TotalAmt, drl.c_invoice_id AS C_Invoice_ID, COALESCE(i.issotrx, p.isreceipt) AS IsSOTrx, COALESCE(i.documentno, p.documentno) AS DocumentNo, COALESCE(i.docstatus, p.docstatus) AS DocStatus, COALESCE(i.dateinvoiced, p.datetrx) AS DateTrx, COALESCE(i.c_doctype_id, p.c_doctype_id) AS C_DocType_ID, COALESCE(dt.printname, dtp.printname) AS DocumentType, COALESCE(i.description, p.description) AS Description, COALESCE(i.c_currency_id, p.c_currency_id) AS C_Currency_ID, COALESCE(i.c_campaign_id, p.c_campaign_id) AS C_Campaign_ID, COALESCE(i.c_project_id, p.c_project_id) AS C_Project_ID, COALESCE(i.c_activity_id, p.c_activity_id) AS C_Activity_ID, COALESCE(i.user1_id, p.user1_id) AS User1_ID, COALESCE(i.user2_id, p.user2_id) AS User2_ID, COALESCE(i.dateacct, p.dateacct) AS DateAcct, COALESCE(i.c_conversiontype_id, p.c_conversiontype_id) AS C_ConversionType_ID, COALESCE(i.ad_orgtrx_id, p.ad_orgtrx_id) AS AD_OrgTrx_ID, i.poreference AS POReference, i.dateordered AS DateOrdered, i.dateinvoiced AS DateInvoiced, i.isindispute AS IsInDispute, pt.name AS PaymentTerm, i.c_charge_id AS C_Charge_ID, i.char
;
-- Nov 28, 2021, 11:19:15 PM CET
CREATE OR REPLACE VIEW M_Transaction_v(M_Transaction_ID, AD_Client_ID, AD_Org_ID, IsActive, Created, CreatedBy, Updated, UpdatedBy, MovementType, M_Locator_ID, M_Product_ID, MovementDate, MovementQty, M_InventoryLine_ID, M_Inventory_ID, M_MovementLine_ID, M_Movement_ID, M_InOutLine_ID, M_InOut_ID, M_ProductionLine_ID, M_Production_ID, C_ProjectIssue_ID, C_Project_ID, M_AttributeSetInstance_ID) AS SELECT t.m_transaction_id AS M_Transaction_ID, t.ad_client_id AS AD_Client_ID, t.ad_org_id AS AD_Org_ID, t.isactive AS IsActive, t.created AS Created, t.createdby AS CreatedBy, t.updated AS Updated, t.updatedby AS UpdatedBy, t.movementtype AS MovementType, t.m_locator_id AS M_Locator_ID, t.m_product_id AS M_Product_ID, t.movementdate AS MovementDate, t.movementqty AS MovementQty, t.m_inventoryline_id AS M_InventoryLine_ID, i.m_inventory_id AS M_Inventory_ID, t.m_movementline_id AS M_MovementLine_ID, m.m_movement_id AS M_Movement_ID, t.m_inoutline_id AS M_InOutLine_ID, io.m_inout_id AS M_InOut_ID, t.m_productionline_id AS M_ProductionLine_ID, pp.m_production_id AS M_Production_ID, t.c_projectissue_id AS C_ProjectIssue_ID, pi.c_project_id AS C_Project_ID, t.m_attributesetinstance_id AS M_AttributeSetInstance_ID FROM m_transaction t LEFT JOIN m_inoutline io ON t.m_inoutline_id = io.m_inoutline_id AND t.m_attributesetinstance_id = io.m_attributesetinstance_id LEFT JOIN m_movementline m ON t.m_movementline_id = m.m_movementline_id AND t.m_attributesetinstance_id = m.m_attributesetinstance_id LEFT JOIN m_inventoryline i ON t.m_inventoryline_id = i.m_inventoryline_id AND t.m_attributesetinstance_id = i.m_attributesetinstance_id LEFT JOIN c_projectissue pi ON t.c_projectissue_id = pi.c_projectissue_id AND t.m_attributesetinstance_id = pi.m_attributesetinstance_id LEFT JOIN m_productionline pl ON t.m_productionline_id = pl.m_productionline_id AND t.m_attributesetinstance_id = pl.m_attributesetinstance_id LEFT JOIN m_productionplan pp ON pl.m_productionplan_id = pp.m_productionplan_id
;
-- Nov 28, 2021, 11:19:15 PM CET
CREATE OR REPLACE VIEW M_Product_Stock_V(IsActive, Created, CreatedBy, Updated, UpdatedBy, Value, Help, QtyAvailable, QtyOnHand, QtyReserved, Description, warehouse, M_Warehouse_ID, AD_Client_ID, AD_Org_ID, DocumentNote, M_Product_ID) AS SELECT ms.isactive AS IsActive, ms.created AS Created, ms.createdby AS CreatedBy, ms.updated AS Updated, ms.updatedby AS UpdatedBy, mp.value AS Value, mp.help AS Help, CASE WHEN COALESCE(lt.isavailableforreservation, 'Y') = 'Y' THEN ms.qtyonhand ELSE 0 END - ms.qtyreserved AS QtyAvailable, ms.qtyonhand AS QtyOnHand, ms.qtyreserved AS QtyReserved, mp.description AS Description, mw.name AS warehouse, mw.m_warehouse_id AS M_Warehouse_ID, mw.ad_client_id AS AD_Client_ID, mw.ad_org_id AS AD_Org_ID, mp.documentnote AS DocumentNote, mp.m_product_id AS M_Product_ID FROM m_storage ms JOIN m_product mp ON ms.m_product_id = mp.m_product_id JOIN m_locator ml ON ms.m_locator_id = ml.m_locator_id LEFT JOIN m_locatortype lt ON ml.m_locatortype_id = lt.m_locatortype_id JOIN m_warehouse mw ON ml.m_warehouse_id = mw.m_warehouse_id ORDER BY mw.name
;
-- Nov 28, 2021, 11:19:15 PM CET
CREATE OR REPLACE VIEW M_Product_SubstituteRelated_V(AD_Client_ID, AD_Org_ID, IsActive, Created, CreatedBy, Updated, UpdatedBy, M_Product_ID, Substitute_ID, rowtype, Name, QtyAvailable, QtyOnHand, QtyReserved, PriceStd, M_PriceList_Version_ID, M_Warehouse_ID, OrgName) AS SELECT s.ad_client_id AS AD_Client_ID, s.ad_org_id AS AD_Org_ID, s.isactive AS IsActive, s.created AS Created, s.createdby AS CreatedBy, s.updated AS Updated, s.updatedby AS UpdatedBy, s.m_product_id AS M_Product_ID, s.substitute_id AS Substitute_ID, 'S' AS rowtype, mp.name AS Name, sum( CASE WHEN COALESCE(lt.isavailableforreservation, 'Y') = 'Y' THEN ms.qtyonhand ELSE 0 END - ms.qtyreserved) AS QtyAvailable, sum(ms.qtyonhand) AS QtyOnHand, sum(ms.qtyreserved) AS QtyReserved, currencyround(max(mpr.pricestd), mpl.c_currency_id, 'N') AS PriceStd, mpr.m_pricelist_version_id AS M_PriceList_Version_ID, mw.m_warehouse_id AS M_Warehouse_ID, org.name AS OrgName FROM m_substitute s JOIN m_storage ms ON ms.m_product_id = s.substitute_id JOIN m_product mp ON ms.m_product_id = mp.m_product_id JOIN m_locator ml ON ms.m_locator_id = ml.m_locator_id LEFT JOIN m_locatortype lt ON ml.m_locatortype_id = lt.m_locatortype_id JOIN m_warehouse mw ON ml.m_warehouse_id = mw.m_warehouse_id JOIN m_productprice mpr ON ms.m_product_id = mpr.m_product_id JOIN m_pricelist_version mplv ON mplv.m_pricelist_version_id = mpr.m_pricelist_version_id JOIN m_pricelist mpl ON mplv.m_pricelist_id = mpl.m_pricelist_id JOIN ad_org org ON org.ad_org_id = mw.ad_org_id GROUP BY s.ad_client_id, s.ad_org_id, s.isactive, s.created, s.createdby, s.updated, s.updatedby, s.m_product_id, s.substitute_id, mw.m_warehouse_id, mpr.m_pricelist_version_id, org.name, mp.name, mpl.c_currency_id UNION SELECT r.ad_client_id AS AD_Client_ID, r.ad_org_id AS AD_Org_ID, r.isactive AS IsActive, r.created AS Created, r.createdby AS CreatedBy, r.updated AS Updated, r.updatedby AS UpdatedBy, r.m_product_id AS M_Product_ID, r.relatedproduct_id AS Substitute_ID, 'R' AS rowtype, mp.name AS Name, sum( CASE WHEN COALESCE(lt.isavailableforreservation, 'Y') = 'Y' THEN ms.qtyonhand ELSE 0 END - ms.qtyreserved) AS QtyAvailable, sum(ms.qtyonhand) AS QtyOnHand, sum(ms.qtyreserved) AS QtyReserved, currencyround(max(mpr.pricestd), mpl.c_currency_id, 'N') AS PriceStd, mpr.m_pricelist_version_id AS M_PriceList_Version_ID, mw.m_warehouse_id AS M_Warehouse_ID, org.name AS OrgName FROM m_relatedproduct r JOIN m_storage ms ON ms.m_product_id = r.relatedproduct_id JOIN m_product mp ON ms.m_product_id = mp.m_product_id JOIN m_locator ml ON ms.m_locator_id = ml.m_locator_id LEFT JOIN m_locatortype lt ON ml.m_locatortype_id = lt.m_locatortype_id JOIN m_warehouse mw ON ml.m_warehouse_id = mw.m_warehouse_id JOIN m_productprice mpr ON ms.m_product_id = mpr.m_product_id JOIN m_pricelist_version mplv ON mplv.m_pricelist_version_id = mpr.m_pricelist_version_id JOIN m_pricelist mpl ON mplv.m_pricelist_id = mpl.m_pricelist_id JOIN ad_org org ON org.ad_org_id = mw.ad_org_id GROUP BY r.ad_client_id, r.ad_org_id, r.isactive, r.created, r.createdby, r.updated, r.updatedby, r.m_product_id, r.relatedproduct_id, mw.m_warehouse_id, mpr.m_pricelist_version_id, org.name, mp.name, mpl.c_currency_id
;
-- Nov 28, 2021, 11:19:15 PM CET
CREATE OR REPLACE VIEW RV_PP_Order_Storage(AD_Client_ID, AD_Org_ID, CreatedBy, UpdatedBy, Updated, Created, IsActive, PP_Order_BOM_ID, PP_Order_BOMLine_ID, PP_Order_ID, IsCritical, M_Product_ID, Name, C_UOM_ID, QtyOnHand, QtyRequiered, QtyBatchSize, QtyReserved, QtyAvailable, M_Warehouse_ID, QtyBOM, IsQtyPercentage, QtyBatch, M_AttributeSetInstance_ID, M_Locator_ID, X, Y, Z) AS SELECT obl.ad_client_id AS AD_Client_ID, obl.ad_org_id AS AD_Org_ID, obl.createdby AS CreatedBy, obl.updatedby AS UpdatedBy, obl.updated AS Updated, obl.created AS Created, obl.isactive AS IsActive, obl.pp_order_bom_id AS PP_Order_BOM_ID, obl.pp_order_bomline_id AS PP_Order_BOMLine_ID, obl.pp_order_id AS PP_Order_ID, obl.iscritical AS IsCritical, obl.m_product_id AS M_Product_ID, ( SELECT p.name FROM m_product p WHERE p.m_product_id = o.m_product_id) AS Name, obl.c_uom_id AS C_UOM_ID, s.qtyonhand AS QtyOnHand, round(obl.qtyrequiered, 4) AS QtyRequiered, CASE WHEN o.qtybatchs = 0 THEN 1 ELSE round(obl.qtyrequiered / o.qtybatchs, 4) END AS QtyBatchSize, round(bomqtyreserved(obl.m_product_id, obl.m_warehouse_id, 0), 4) AS QtyReserved, round(bomqtyavailable(obl.m_product_id, obl.m_warehouse_id, 0), 4) AS QtyAvailable, obl.m_warehouse_id AS M_Warehouse_ID, obl.qtybom AS QtyBOM, obl.isqtypercentage AS IsQtyPercentage, round(obl.qtybatch, 4) AS QtyBatch, obl.m_attributesetinstance_id AS M_AttributeSetInstance_ID, l.m_locator_id AS M_Locator_ID, l.x AS X, l.y AS Y, l.z AS Z FROM pp_order_bomline obl JOIN pp_order o ON o.pp_order_id = obl.pp_order_id LEFT JOIN m_storage s ON s.m_product_id = obl.m_product_id AND s.qtyonhand <> 0 AND obl.m_warehouse_id = (SELECT ld.m_warehouse_id FROM m_locator ld WHERE s.m_locator_id = ld.m_locator_id) LEFT JOIN m_locator l ON l.m_locator_id = s.m_locator_id ORDER BY obl.m_product_id
;
-- Nov 28, 2021, 11:19:15 PM CET
CREATE OR REPLACE VIEW RV_PP_Product_BOMLine(SeqNo, LevelNo, Levels, AD_Client_ID, AD_Org_ID, CreatedBy, UpdatedBy, Updated, Created, AD_PInstance_ID, Implosion, M_Product_ID, IsActive, PP_Product_BOM_ID, PP_Product_BOMLine_ID, Description, IsCritical, ComponentType, TM_Product_ID, C_UOM_ID, IssueMethod, Line, M_AttributeSetInstance_ID, Scrap, ValidFrom, ValidTo, QtyBOM, QtyBatch, IsQtyPercentage) AS SELECT t.seqno AS SeqNo, t.levelno AS LevelNo, t.levels AS Levels, t.ad_client_id AS AD_Client_ID, t.ad_org_id AS AD_Org_ID, t.createdby AS CreatedBy, t.updatedby AS UpdatedBy, t.updated AS Updated, t.created AS Created, t.ad_pinstance_id AS AD_PInstance_ID, t.implosion AS Implosion, t.sel_product_id AS M_Product_ID, bl.isactive AS IsActive, bl.pp_product_bom_id AS PP_Product_BOM_ID, bl.pp_product_bomline_id AS PP_Product_BOMLine_ID, bl.description AS Description, bl.iscritical AS IsCritical, bl.componenttype AS ComponentType, t.m_product_id AS TM_Product_ID, bl.c_uom_id AS C_UOM_ID, bl.issuemethod AS IssueMethod, bl.line AS Line, bl.m_attributesetinstance_id AS M_AttributeSetInstance_ID, bl.scrap AS Scrap, bl.validfrom AS ValidFrom, bl.validto AS ValidTo, bl.qtybom AS QtyBOM, bl.qtybatch AS QtyBatch, bl.isqtypercentage AS IsQtyPercentage FROM t_bomline t LEFT JOIN pp_product_bomline bl ON t.pp_product_bomline_id = bl.pp_product_bomline_id
;
-- Nov 28, 2021, 11:19:15 PM CET
CREATE OR REPLACE VIEW RV_PP_Order_Transactions(AD_Client_ID, AD_Org_ID, IsActive, Created, CreatedBy, UpdatedBy, Updated, DocumentNo, M_Product_ID, M_Locator_ID, MovementDate, PP_Order_ID, QtyDelivered, QtyScrap, QtyDeliveredLine, QtyIssueShouldBe, QtyScrapLine, QtyIssueScrapShouldBe, createdbyissue, updatedbyissue, QtyToDeliver, DifferenceQty, IsSOTrx, DateOrdered) AS SELECT DISTINCT o.ad_client_id AS AD_Client_ID, o.ad_org_id AS AD_Org_ID, o.isactive AS IsActive, o.created AS Created, o.createdby AS CreatedBy, o.updatedby AS UpdatedBy, o.updated AS Updated, o.documentno AS DocumentNo, ol.m_product_id AS M_Product_ID, mt.m_locator_id AS M_Locator_ID, mt.movementdate AS MovementDate, o.pp_order_id AS PP_Order_ID, o.qtydelivered AS QtyDelivered, o.qtyscrap AS QtyScrap, ol.qtydelivered AS QtyDeliveredLine, o.qtydelivered * ol.qtybatch / 100 AS QtyIssueShouldBe, ol.qtyscrap AS QtyScrapLine, o.qtyscrap * ol.qtybatch / 100 AS QtyIssueScrapShouldBe, mt.createdby AS createdbyissue, mt.updatedby AS updatedbyissue, ( SELECT sum(t.movementqty) AS sum FROM m_transaction t WHERE t.pp_cost_collector_id = cc.pp_cost_collector_id) AS QtyToDeliver, (o.qtydelivered + o.qtyscrap) * ol.qtybatch / 100 + (( SELECT sum(t.movementqty) AS sum FROM m_transaction t WHERE t.pp_cost_collector_id = cc.pp_cost_collector_id)) AS DifferenceQty, o.issotrx AS IsSOTrx, o.dateordered AS DateOrdered FROM pp_order o JOIN pp_order_bomline ol ON ol.pp_order_id = o.pp_order_id JOIN pp_cost_collector cc ON cc.pp_order_bomline_id = ol.pp_order_bomline_id LEFT JOIN m_transaction mt ON mt.pp_cost_collector_id = cc.pp_cost_collector_id ORDER BY o.ad_client_id, o.ad_org_id, o.isactive, o.created, o.createdby, o.updatedby, o.updated, o.documentno, ol.m_product_id, mt.m_locator_id, mt.movementdate, o.pp_order_id, o.qtydelivered, o.qtyscrap, ol.qtydelivered, (o.qtydelivered * ol.qtybatch / 100), ol.qtyscrap, (o.qtyscrap * ol.qtybatch / 100), mt.createdby, mt.updatedby, QtyToDeliver, DifferenceQty, o.issotrx, o.dateordered
;
-- Nov 28, 2021, 11:19:15 PM CET
CREATE OR REPLACE VIEW DD_Order_Header_v(AD_Client_ID, AD_Org_ID, IsActive, Created, CreatedBy, Updated, UpdatedBy, AD_Language, DD_Order_ID, C_Order_ID, IsSOTrx, DocumentNo, DocStatus, C_DocType_ID, C_BPartner_ID, BPValue, BPTaxID, NAICS, DUNS, Org_Location_ID, TaxID, M_Warehouse_ID, Warehouse_Location_ID, DocumentType, DocumentTypeNote, SalesRep_ID, SalesRep_Name, DateOrdered, DatePromised, BPGreeting, Name, Name2, BPContactGreeting, Title, Phone, ContactName, C_Location_ID, Postal, ReferenceNo, Description, POReference, C_Charge_ID, ChargeAmt, Volume, Weight, C_Campaign_ID, C_Project_ID, C_Activity_ID, M_Shipper_ID, DeliveryRule, DeliveryViaRule, PriorityRule, Logo_ID) AS SELECT o.ad_client_id AS AD_Client_ID, o.ad_org_id AS AD_Org_ID, o.isactive AS IsActive, o.created AS Created, o.createdby AS CreatedBy, o.updated AS Updated, o.updatedby AS UpdatedBy, CAST('en_US' AS CHARACTER VARYING(6)) AS AD_Language, o.dd_order_id AS DD_Order_ID, o.c_order_id AS C_Order_ID, o.issotrx AS IsSOTrx, o.documentno AS DocumentNo, o.docstatus AS DocStatus, o.c_doctype_id AS C_DocType_ID, o.c_bpartner_id AS C_BPartner_ID, bp.value AS BPValue, bp.taxid AS BPTaxID, bp.naics AS NAICS, bp.duns AS DUNS, oi.c_location_id AS Org_Location_ID, oi.taxid AS TaxID, o.m_warehouse_id AS M_Warehouse_ID, wh.c_location_id AS Warehouse_Location_ID, dt.printname AS DocumentType, dt.documentnote AS DocumentTypeNote, o.salesrep_id AS SalesRep_ID, COALESCE(ubp.name, u.name) AS SalesRep_Name, o.dateordered AS DateOrdered, o.datepromised AS DatePromised, bpg.greeting AS BPGreeting, bp.name AS Name, bp.name2 AS Name2, bpcg.greeting AS BPContactGreeting, bpc.title AS Title, bpc.phone AS Phone, NULLIF(bpc.name, bp.name) AS ContactName, bpl.c_location_id AS C_Location_ID, l.postal || l.postal_add AS Postal, bp.referenceno AS ReferenceNo, o.description AS Description, o.poreference AS POReference, o.c_charge_id AS C_Charge_ID, o.chargeamt AS ChargeAmt, o.volume AS Volume, o.weight AS Weight, o.c_campaign_id AS C_Campaign_ID, o.c_project_id AS C_Project_ID, o.c_activity_id AS C_Activity_ID, o.m_shipper_id AS M_Shipper_ID, o.deliveryrule AS DeliveryRule, o.deliveryviarule AS DeliveryViaRule, o.priorityrule AS PriorityRule, COALESCE(oi.logo_id, ci.logo_id) AS Logo_ID FROM dd_order o JOIN c_doctype dt ON o.c_doctype_id = dt.c_doctype_id JOIN m_warehouse wh ON o.m_warehouse_id = wh.m_warehouse_id JOIN c_bpartner bp ON o.c_bpartner_id = bp.c_bpartner_id LEFT JOIN c_greeting bpg ON bp.c_greeting_id = bpg.c_greeting_id JOIN c_bpartner_location bpl ON o.c_bpartner_location_id = bpl.c_bpartner_location_id JOIN c_location l ON bpl.c_location_id = l.c_location_id LEFT JOIN ad_user bpc ON o.ad_user_id = bpc.ad_user_id LEFT JOIN c_greeting bpcg ON bpc.c_greeting_id = bpcg.c_greeting_id JOIN ad_orginfo oi ON o.ad_org_id = oi.ad_org_id JOIN ad_clientinfo ci ON o.ad_client_id = ci.ad_client_id LEFT JOIN ad_user u ON o.salesrep_id = u.ad_user_id LEFT JOIN c_bpartner ubp ON u.c_bpartner_id = ubp.c_bpartner_id
;
-- Nov 28, 2021, 11:19:16 PM CET
CREATE OR REPLACE VIEW RV_PP_Order_BOMLine(AD_Client_ID, AD_Org_ID, CreatedBy, UpdatedBy, Updated, Created, IsActive, PP_Order_BOM_ID, PP_Order_BOMLine_ID, PP_Order_ID, IsCritical, ComponentType, M_Product_ID, C_UOM_ID, QtyRequiered, QtyReserved, QtyAvailable, QtyOnHand, M_Warehouse_ID, QtyBOM, IsQtyPercentage, QtyBatch, QtyBatchSize) AS SELECT obl.ad_client_id AS AD_Client_ID, obl.ad_org_id AS AD_Org_ID, obl.createdby AS CreatedBy, obl.updatedby AS UpdatedBy, obl.updated AS Updated, obl.created AS Created, obl.isactive AS IsActive, obl.pp_order_bom_id AS PP_Order_BOM_ID, obl.pp_order_bomline_id AS PP_Order_BOMLine_ID, obl.pp_order_id AS PP_Order_ID, obl.iscritical AS IsCritical, obl.componenttype AS ComponentType, obl.m_product_id AS M_Product_ID, obl.c_uom_id AS C_UOM_ID, round(obl.qtyrequiered, 4) AS QtyRequiered, round(bomqtyreserved(obl.m_product_id, obl.m_warehouse_id, 0), 4) AS QtyReserved, round(bomqtyavailable(obl.m_product_id, obl.m_warehouse_id, 0), 4) AS QtyAvailable, round(bomqtyonhand(obl.m_product_id, obl.m_warehouse_id, 0), 4) AS QtyOnHand, obl.m_warehouse_id AS M_Warehouse_ID, round(obl.qtybom, 4) AS QtyBOM, obl.isqtypercentage AS IsQtyPercentage, round(obl.qtybatch, 4) AS QtyBatch, CASE WHEN o.qtybatchs = 0 THEN 1 ELSE round(obl.qtyrequiered / o.qtybatchs, 4) END AS QtyBatchSize FROM pp_order_bomline obl JOIN pp_order o ON o.pp_order_id = obl.pp_order_id
;
-- Nov 28, 2021, 11:19:16 PM CET
CREATE OR REPLACE VIEW Fact_Acct_Balance(AD_Client_ID, AD_Org_ID, C_AcctSchema_ID, DateAcct, Account_ID, PostingType, M_Product_ID, C_BPartner_ID, C_Project_ID, AD_OrgTrx_ID, C_SalesRegion_ID, C_Activity_ID, C_Campaign_ID, C_LocTo_ID, C_LocFrom_ID, User1_ID, User2_ID, GL_Budget_ID, AmtAcctDr, AmtAcctCr, Qty, CreatedBy, Created, UpdatedBy, Updated, IsActive, C_SubAcct_ID, UserElement1_ID, UserElement2_ID, C_ProjectPhase_ID, C_ProjectTask_ID) AS SELECT a.ad_client_id AS AD_Client_ID, a.ad_org_id AS AD_Org_ID, a.c_acctschema_id AS C_AcctSchema_ID, trunc(a.dateacct) AS DateAcct, a.account_id AS Account_ID, a.postingtype AS PostingType, a.m_product_id AS M_Product_ID, a.c_bpartner_id AS C_BPartner_ID, a.c_project_id AS C_Project_ID, a.ad_orgtrx_id AS AD_OrgTrx_ID, a.c_salesregion_id AS C_SalesRegion_ID, a.c_activity_id AS C_Activity_ID, a.c_campaign_id AS C_Campaign_ID, a.c_locto_id AS C_LocTo_ID, a.c_locfrom_id AS C_LocFrom_ID, a.user1_id AS User1_ID, a.user2_id AS User2_ID, a.gl_budget_id AS GL_Budget_ID, COALESCE(sum(a.amtacctdr), 0) AS AmtAcctDr, COALESCE(sum(a.amtacctcr), 0) AS AmtAcctCr, COALESCE(sum(a.qty), 0) AS Qty, max(a.createdby) AS CreatedBy, max(a.created) AS Created, max(a.updatedby) AS UpdatedBy, max(a.updated) AS Updated, max(a.isactive) AS IsActive, max(a.c_subacct_id) AS C_SubAcct_ID, a.userelement1_id AS UserElement1_ID, a.userelement2_id AS UserElement2_ID, max(a.c_projectphase_id) AS C_ProjectPhase_ID, max(a.c_projecttask_id) AS C_ProjectTask_ID FROM fact_acct a GROUP BY a.ad_client_id, a.ad_org_id, a.c_acctschema_id, (trunc(a.dateacct)), a.account_id, a.postingtype, a.m_product_id, a.c_bpartner_id, a.c_project_id, a.ad_orgtrx_id, a.c_salesregion_id, a.c_activity_id, a.c_campaign_id, a.c_locto_id, a.c_locfrom_id, a.user1_id, a.user2_id, a.userelement1_id, a.userelement2_id, a.gl_budget_id
;
-- Nov 28, 2021, 11:19:16 PM CET
CREATE OR REPLACE VIEW RV_DD_OrderDetail(AD_Client_ID, AD_Org_ID, IsActive, Created, CreatedBy, Updated, UpdatedBy, DD_Order_ID, C_Order_ID, DocStatus, DocAction, C_DocType_ID, IsApproved, SalesRep_ID, IsDropShip, C_BPartner_ID, C_BP_Group_ID, AD_User_ID, POReference, IsSOTrx, C_Campaign_ID, C_Project_ID, C_Activity_ID, DD_OrderLine_ID, DateOrdered, DatePromised, M_Product_ID, M_Locator_ID, M_LocatorTo_ID, M_AttributeSetInstance_ID, ProductAttribute, M_AttributeSetInstanceTo_ID, ProductAttributeTo, M_AttributeSet_ID, M_Lot_ID, GuaranteeDate, Lot, SerNo, C_UOM_ID, QtyEntered, QtyOrdered, QtyReserved, QtyDelivered, ConfirmedQty, QtyInTransit, TargetQty, QtyToDeliver, Description) AS SELECT l.ad_client_id AS AD_Client_ID, l.ad_org_id AS AD_Org_ID, l.isactive AS IsActive, l.created AS Created, l.createdby AS CreatedBy, l.updated AS Updated, l.updatedby AS UpdatedBy, o.dd_order_id AS DD_Order_ID, o.c_order_id AS C_Order_ID, o.docstatus AS DocStatus, o.docaction AS DocAction, o.c_doctype_id AS C_DocType_ID, o.isapproved AS IsApproved, o.salesrep_id AS SalesRep_ID, o.isdropship AS IsDropShip, o.c_bpartner_id AS C_BPartner_ID, bp.c_bp_group_id AS C_BP_Group_ID, o.ad_user_id AS AD_User_ID, o.poreference AS POReference, o.issotrx AS IsSOTrx, l.c_campaign_id AS C_Campaign_ID, l.c_project_id AS C_Project_ID, l.c_activity_id AS C_Activity_ID, l.dd_orderline_id AS DD_OrderLine_ID, l.dateordered AS DateOrdered, l.datepromised AS DatePromised, l.m_product_id AS M_Product_ID, l.m_locator_id AS M_Locator_ID, l.m_locatorto_id AS M_LocatorTo_ID, l.m_attributesetinstance_id AS M_AttributeSetInstance_ID, productattribute(l.m_attributesetinstance_id) AS ProductAttribute, l.m_attributesetinstanceto_id AS M_AttributeSetInstanceTo_ID, productattribute(l.m_attributesetinstanceto_id) AS ProductAttributeTo, pasi.m_attributeset_id AS M_AttributeSet_ID, pasi.m_lot_id AS M_Lot_ID, pasi.guaranteedate AS GuaranteeDate, pasi.lot AS Lot, pasi.serno AS SerNo, l.c_uom_id AS C_UOM_ID, l.qtyentered AS QtyEntered, l.qtyordered AS QtyOrdered, l.qtyreserved AS QtyReserved, l.qtydelivered AS QtyDelivered, l.confirmedqty AS ConfirmedQty, l.qtyintransit AS QtyInTransit, l.targetqty AS TargetQty, l.qtyordered - l.qtydelivered AS QtyToDeliver, l.description AS Description FROM dd_order o JOIN dd_orderline l ON l.dd_order_id = o.dd_order_id JOIN c_bpartner bp ON bp.c_bpartner_id = o.c_bpartner_id LEFT JOIN m_attributesetinstance pasi ON l.m_attributesetinstance_id = pasi.m_attributesetinstance_id LEFT JOIN m_attributesetinstance pasito ON l.m_attributesetinstanceto_id = pasito.m_attributesetinstance_id
;
-- Nov 28, 2021, 11:19:16 PM CET
CREATE OR REPLACE VIEW RV_M_Forecast(AD_Client_ID, AD_Org_ID, M_Forecast_ID, Name, C_Calendar_ID, C_Year_ID, C_Period_ID, DatePromised, M_Product_ID, SalesRep_ID, C_UOM_ID, Qty, QtyCalculated, PriceList, PriceStd, PriceLimit, TotalAmt, M_Product_Category_ID, Classification, Group1, Group2) AS SELECT f.ad_client_id AS AD_Client_ID, fl.ad_org_id AS AD_Org_ID, f.m_forecast_id AS M_Forecast_ID, f.name AS Name, f.c_calendar_id AS C_Calendar_ID, f.c_year_id AS C_Year_ID, fl.c_period_id AS C_Period_ID, fl.datepromised AS DatePromised, fl.m_product_id AS M_Product_ID, fl.salesrep_id AS SalesRep_ID, p.c_uom_id AS C_UOM_ID, fl.qty AS Qty, fl.qtycalculated AS QtyCalculated, ( SELECT pp.pricelist FROM m_pricelist_version plv JOIN m_productprice pp ON pp.m_pricelist_version_id = plv.m_pricelist_version_id WHERE pp.m_product_id = fl.m_product_id AND plv.m_pricelist_id = pl.m_pricelist_id) AS PriceList, ( SELECT pp.pricestd FROM m_pricelist_version plv JOIN m_productprice pp ON pp.m_pricelist_version_id = plv.m_pricelist_version_id WHERE pp.m_product_id = fl.m_product_id AND plv.m_pricelist_id = pl.m_pricelist_id) AS PriceStd, ( SELECT pp.pricelimit FROM m_pricelist_version plv JOIN m_productprice pp ON pp.m_pricelist_version_id = plv.m_pricelist_version_id WHERE pp.m_product_id = fl.m_product_id AND plv.m_pricelist_id = pl.m_pricelist_id) AS PriceLimit, (( SELECT pp.pricestd FROM m_pricelist_version plv JOIN m_productprice pp ON pp.m_pricelist_version_id = plv.m_pricelist_version_id WHERE pp.m_product_id = fl.m_product_id AND plv.m_pricelist_id = pl.m_pricelist_id)) * fl.qty AS TotalAmt, p.m_product_category_id AS M_Product_Category_ID, p.classification AS Classification, p.group1 AS Group1, p.group2 AS Group2 FROM m_forecast f JOIN m_forecastline fl ON f.m_forecast_id = fl.m_forecast_id JOIN m_product p ON p.m_product_id = fl.m_product_id JOIN m_pricelist pl ON pl.m_pricelist_id = f.m_pricelist_id
;
-- Nov 28, 2021, 11:19:16 PM CET
CREATE OR REPLACE VIEW RV_M_Forecast_Period(AD_Client_ID, AD_Org_ID, M_Forecast_ID, Name, C_Calendar_ID, C_Year_ID, C_Period_ID, M_Product_ID, C_UOM_ID, Qty, QtyCalculated, TotalAmt) AS SELECT f.ad_client_id AS AD_Client_ID, f.ad_org_id AS AD_Org_ID, f.m_forecast_id AS M_Forecast_ID, max(f.name) AS Name, f.c_calendar_id AS C_Calendar_ID, f.c_year_id AS C_Year_ID, f.c_period_id AS C_Period_ID, f.m_product_id AS M_Product_ID, f.c_uom_id AS C_UOM_ID, sum(f.qty) AS Qty, sum(f.qtycalculated) AS QtyCalculated, sum(f.totalamt) AS TotalAmt FROM rv_m_forecast f GROUP BY f.ad_client_id, f.ad_org_id, f.m_forecast_id, f.m_product_id, f.c_uom_id, f.c_calendar_id, f.c_year_id, f.c_period_id
;
-- Nov 28, 2021, 11:19:16 PM CET
CREATE OR REPLACE VIEW RV_PP_Order_Workflow(AD_Client_ID, AD_Org_ID, Created, CreatedBy, IsActive, Updated, UpdatedBy, PP_Order_Workflow_ID, Name, PP_Order_ID, DocStatus, Value, S_Resource_ID, DurationRequiered, DurationReal, Duration, MovingTime, WaitingTime, SetupTime, QueuingTime, QtyDelivered, QtyReject, QtyScrap, DateStartSchedule, DateFinishSchedule, C_BPartner_ID, Description, IsMilestone, IsSubcontracting) AS SELECT n.ad_client_id AS AD_Client_ID, n.ad_org_id AS AD_Org_ID, n.created AS Created, n.createdby AS CreatedBy, n.isactive AS IsActive, n.updated AS Updated, n.updatedby AS UpdatedBy, owf.pp_order_workflow_id AS PP_Order_Workflow_ID, n.name AS Name, n.pp_order_id AS PP_Order_ID, n.docstatus AS DocStatus, n.value AS Value, n.s_resource_id AS S_Resource_ID, n.durationrequiered AS DurationRequiered, n.durationreal AS DurationReal, n.durationrequiered - n.durationreal AS Duration, n.movingtime AS MovingTime, n.waitingtime AS WaitingTime, n.setuptime AS SetupTime, n.queuingtime AS QueuingTime, n.qtydelivered AS QtyDelivered, n.qtyreject AS QtyReject, n.qtyscrap AS QtyScrap, n.datestartschedule AS DateStartSchedule, n.datefinishschedule AS DateFinishSchedule, n.c_bpartner_id AS C_BPartner_ID, n.description AS Description, n.ismilestone AS IsMilestone, n.issubcontracting AS IsSubcontracting FROM pp_order_workflow owf JOIN pp_order_node n ON n.pp_order_workflow_id = owf.pp_order_workflow_id
;
-- Nov 28, 2021, 11:19:16 PM CET
CREATE OR REPLACE VIEW T_BOMLine_Costs(SeqNo, LevelNo, Levels, AD_Client_ID, C_AcctSchema_ID, AD_Org_ID, CreatedBy, UpdatedBy, Updated, Created, AD_PInstance_ID, Implosion, M_Product_ID, M_CostElement_ID, CurrentCostPrice, CurrentCostPriceLL, FutureCostPrice, FutureCostPriceLL, IsCostFrozen, QtyBOM, Cost, CostStandard, M_CostType_ID, CostingMethod, IsActive, PP_Product_BOM_ID, PP_Product_BOMLine_ID, Description, IsCritical, ComponentType, TM_Product_ID, C_UOM_ID, IssueMethod, Line, M_AttributeSetInstance_ID, Scrap, ValidFrom, ValidTo, IsQtyPercentage) AS SELECT t.seqno AS SeqNo, t.levelno AS LevelNo, t.levels AS Levels, t.ad_client_id AS AD_Client_ID, t.c_acctschema_id AS C_AcctSchema_ID, t.ad_org_id AS AD_Org_ID, t.createdby AS CreatedBy, t.updatedby AS UpdatedBy, t.updated AS Updated, t.created AS Created, t.ad_pinstance_id AS AD_PInstance_ID, t.implosion AS Implosion, t.sel_product_id AS M_Product_ID, t.m_costelement_id AS M_CostElement_ID, t.currentcostprice AS CurrentCostPrice, t.currentcostpricell AS CurrentCostPriceLL, t.futurecostprice AS FutureCostPrice, t.futurecostpricell AS FutureCostPriceLL, t.iscostfrozen AS IsCostFrozen, t.qtybom AS QtyBOM, (t.currentcostprice + t.currentcostpricell) * t.qtybom AS Cost, (t.futurecostprice + t.futurecostpricell) * t.qtybom AS CostStandard, t.m_costtype_id AS M_CostType_ID, t.costingmethod AS CostingMethod, bl.isactive AS IsActive, bl.pp_product_bom_id AS PP_Product_BOM_ID, bl.pp_product_bomline_id AS PP_Product_BOMLine_ID, bl.description AS Description, bl.iscritical AS IsCritical, bl.componenttype AS ComponentType, t.m_product_id AS TM_Product_ID, bl.c_uom_id AS C_UOM_ID, bl.issuemethod AS IssueMethod, bl.line AS Line, bl.m_attributesetinstance_id AS M_AttributeSetInstance_ID, bl.scrap AS Scrap, bl.validfrom AS ValidFrom, bl.validto AS ValidTo, bl.isqtypercentage AS IsQtyPercentage FROM t_bomline t LEFT JOIN pp_product_bomline bl ON t.pp_product_bomline_id = bl.pp_product_bomline_id
;
-- Nov 28, 2021, 11:19:16 PM CET
CREATE OR REPLACE VIEW PP_Order_BOM_Header_v(AD_Client_ID, AD_Org_ID, IsActive, Created, CreatedBy, Updated, UpdatedBy, AD_Language, PP_Order_ID, DocumentNo, DocStatus, C_DocType_ID, Org_Location_ID, TaxID, M_Warehouse_ID, Warehouse_Location_ID, DocumentType, DocumentTypeNote, Planner_ID, SalesRep_Name, DateStart, DateStartSchedule, FloatAfter, FloatBefored, Line, Lot, SerNo, C_UOM_ID, S_Resource_ID, PP_Product_BOM_ID, AD_Workflow_ID, Assay, C_OrderLine_ID, PriorityRule, QtyBatchSize, QtyBatchs, QtyDelivered, QtyEntered, QtyOrdered, DateConfirm, DateDelivered, DateFinish, DateFinishSchedule, DateOrdered, DatePromised, QtyReject, QtyReserved, QtyScrap, Yield, C_Campaign_ID, C_Project_ID, C_Activity_ID, BOMType, BOMUse, Description, Help, M_AttributeSetInstance_ID, M_Product_ID, Name, Revision, ValidFrom, ValidTo, Logo_ID) AS SELECT o.ad_client_id AS AD_Client_ID, o.ad_org_id AS AD_Org_ID, o.isactive AS IsActive, o.created AS Created, o.createdby AS CreatedBy, o.updated AS Updated, o.updatedby AS UpdatedBy, CAST('en_US' AS CHARACTER VARYING(6)) AS AD_Language, o.pp_order_id AS PP_Order_ID, o.documentno AS DocumentNo, o.docstatus AS DocStatus, o.c_doctype_id AS C_DocType_ID, oi.c_location_id AS Org_Location_ID, oi.taxid AS TaxID, o.m_warehouse_id AS M_Warehouse_ID, wh.c_location_id AS Warehouse_Location_ID, d.printname AS DocumentType, d.documentnote AS DocumentTypeNote, o.planner_id AS Planner_ID, u.name AS SalesRep_Name, o.datestart AS DateStart, o.datestartschedule AS DateStartSchedule, o.floatafter AS FloatAfter, o.floatbefored AS FloatBefored, o.line AS Line, o.lot AS Lot, o.serno AS SerNo, o.c_uom_id AS C_UOM_ID, o.s_resource_id AS S_Resource_ID, o.pp_product_bom_id AS PP_Product_BOM_ID, o.ad_workflow_id AS AD_Workflow_ID, o.assay AS Assay, o.c_orderline_id AS C_OrderLine_ID, o.priorityrule AS PriorityRule, o.qtybatchsize AS QtyBatchSize, o.qtybatchs AS QtyBatchs, o.qtydelivered AS QtyDelivered, o.qtyentered AS QtyEntered, o.qtyordered AS QtyOrdered, o.dateconfirm AS DateConfirm, o.datedelivered AS DateDelivered, o.datefinish AS DateFinish, o.datefinishschedule AS DateFinishSchedule, o.dateordered AS DateOrdered, o.datepromised AS DatePromised, o.qtyreject AS QtyReject, o.qtyreserved AS QtyReserved, o.qtyscrap AS QtyScrap, o.yield AS Yield, o.c_campaign_id AS C_Campaign_ID, o.c_project_id AS C_Project_ID, o.c_activity_id AS C_Activity_ID, ob.bomtype AS BOMType, ob.bomuse AS BOMUse, ob.description AS Description, ob.help AS Help, ob.m_attributesetinstance_id AS M_AttributeSetInstance_ID, ob.m_product_id AS M_Product_ID, ob.name AS Name, ob.revision AS Revision, ob.validfrom AS ValidFrom, ob.validto AS ValidTo, COALESCE(oi.logo_id, ci.logo_id) AS Logo_ID FROM pp_order o JOIN c_doctype d ON o.c_doctype_id = d.c_doctype_id JOIN pp_order_bom ob ON ob.pp_order_id = o.pp_order_id JOIN m_warehouse wh ON o.m_warehouse_id = wh.m_warehouse_id JOIN ad_orginfo oi ON o.ad_org_id = oi.ad_org_id JOIN ad_clientinfo ci ON o.ad_client_id = ci.ad_client_id LEFT JOIN ad_user u ON o.planner_id = u.ad_user_id
;
-- Nov 28, 2021, 11:19:16 PM CET
CREATE OR REPLACE VIEW RV_Unprocessed(AD_Client_ID, AD_Org_ID, Created, CreatedBy, Updated, UpdatedBy, IsActive, DocumentNo, DateDoc, DateAcct, AD_Table_ID, Record_ID, IsSOTrx, Posted, Processing, Processed, DocStatus) AS SELECT gl_journal.ad_client_id AS AD_Client_ID, gl_journal.ad_org_id AS AD_Org_ID, gl_journal.created AS Created, gl_journal.createdby AS CreatedBy, gl_journal.updated AS Updated, gl_journal.updatedby AS UpdatedBy, gl_journal.isactive AS IsActive, gl_journal.documentno AS DocumentNo, gl_journal.datedoc AS DateDoc, gl_journal.dateacct AS DateAcct, 224 AS AD_Table_ID, gl_journal.gl_journal_id AS Record_ID, 'N' AS IsSOTrx, gl_journal.posted AS Posted, gl_journal.processing AS Processing, gl_journal.processed AS Processed, gl_journal.docstatus AS DocStatus FROM gl_journal WHERE gl_journal.docstatus NOT IN ('CO', 'CL', 'VO', 'RE') UNION SELECT c_invoice.ad_client_id AS AD_Client_ID, c_invoice.ad_org_id AS AD_Org_ID, c_invoice.created AS Created, c_invoice.createdby AS CreatedBy, c_invoice.updated AS Updated, c_invoice.updatedby AS UpdatedBy, c_invoice.isactive AS IsActive, c_invoice.documentno AS DocumentNo, c_invoice.dateinvoiced AS DateDoc, c_invoice.dateacct AS DateAcct, 318 AS AD_Table_ID, c_invoice.c_invoice_id AS Record_ID, c_invoice.issotrx AS IsSOTrx, c_invoice.posted AS Posted, c_invoice.processing AS Processing, c_invoice.processed AS Processed, c_invoice.docstatus AS DocStatus FROM c_invoice WHERE c_invoice.docstatus NOT IN ('CO', 'CL', 'VO', 'RE') UNION SELECT m_inout.ad_client_id AS AD_Client_ID, m_inout.ad_org_id AS AD_Org_ID, m_inout.created AS Created, m_inout.createdby AS CreatedBy, m_inout.updated AS Updated, m_inout.updatedby AS UpdatedBy, m_inout.isactive AS IsActive, m_inout.documentno AS DocumentNo, m_inout.movementdate AS DateDoc, m_inout.dateacct AS DateAcct, 319 AS AD_Table_ID, m_inout.m_inout_id AS Record_ID, m_inout.issotrx AS IsSOTrx, m_inout.posted AS Posted, m_inout.processing AS Processing, m_inout.processed AS Processed, m_inout.docstatus AS DocStatus FROM m_inout WHERE m_inout.docstatus NOT IN ('CO', 'CL', 'VO', 'RE') UNION SELECT m_inventory.ad_client_id AS AD_Client_ID, m_inventory.ad_org_id AS AD_Org_ID, m_inventory.created AS Created, m_inventory.createdby AS CreatedBy, m_inventory.updated AS Updated, m_inventory.updatedby AS UpdatedBy, m_inventory.isactive AS IsActive, m_inventory.documentno AS DocumentNo, m_inventory.movementdate AS DateDoc, m_inventory.movementdate AS DateAcct, 321 AS AD_Table_ID, m_inventory.m_inventory_id AS Record_ID, 'N' AS IsSOTrx, m_inventory.posted AS Posted, m_inventory.processing AS Processing, m_inventory.processed AS Processed, m_inventory.docstatus AS DocStatus FROM m_inventory WHERE m_inventory.docstatus NOT IN ('CO', 'CL', 'VO', 'RE') UNION SELECT m_movement.ad_client_id AS AD_Client_ID, m_movement.ad_org_id AS AD_Org_ID, m_movement.created AS Created, m_movement.createdby AS CreatedBy, m_movement.updated AS Updated, m_movement.updatedby AS UpdatedBy, m_movement.isactive AS IsActive, m_movement.documentno AS DocumentNo, m_movement.movementdate AS DateDoc, m_movement.movementdate AS DateAcct, 323 AS AD_Table_ID, m_movement.m_movement_id AS Record_ID, 'N' AS IsSOTrx, m_movement.posted AS Posted, m_movement.processing AS Processing, m_movement.processed AS Processed, m_movement.docstatus AS DocStatus FROM m_movement WHERE m_movement.docstatus NOT IN ('CO', 'CL', 'VO', 'RE') UNION SELECT c_cash.ad_client_id AS AD_Client_ID, c_cash.ad_org_id AS AD_Org_ID, c_cash.created AS Created, c_cash.createdby AS CreatedBy, c_cash.updated AS Updated, c_cash.updatedby AS UpdatedBy, c_cash.isactive AS IsActive, c_cash.name AS DocumentNo, c_cash.statementdate AS DateDoc, c_cash.dateacct AS DateAcct, 407 AS AD_Table_ID, c_cash.c_cash_id AS Record_ID, 'N' AS IsSOTrx, c_cash.posted AS Posted, c_cash.processing AS Processing, c_cash.processed AS Processed, c_cash.docstatus AS DocStatus FROM c_cash WHERE c_cash.docstatus NOT IN ('CO', 'CL', 'VO', 'RE') UNION SELECT c_payment.ad_client_id AS AD_Client_ID, c_payment.ad_org_id AS AD_Org_ID, c_payment.created AS Cre
;
-- Nov 28, 2021, 11:19:16 PM CET
CREATE OR REPLACE VIEW PP_Order_BOMLine_v(AD_Client_ID, AD_Org_ID, IsActive, Created, CreatedBy, Updated, UpdatedBy, AD_Language, Description, Feature, M_Product_ID, BackflushGroup, C_UOM_ID, ComponentType, DateDelivered, Forecast, Help, IsCritical, IssueMethod, LeadTimeOffset, Line, M_AttributeSetInstance_ID, M_ChangeNotice_ID, M_Locator_ID, M_Warehouse_ID, PP_Order_BOM_ID, PP_Order_BOMLine_ID, PP_Order_ID, QtyDelivered, QtyPost, QtyReject, QtyScrap, Scrap, ValidFrom, ValidTo, Assay, AD_User_ID, QtyRequiered, QtyReserved, QtyAvailable, QtyOnHand, QtyBOM, IsQtyPercentage, QtyBatch, QtyBatchSize) AS SELECT obl.ad_client_id AS AD_Client_ID, obl.ad_org_id AS AD_Org_ID, obl.isactive AS IsActive, obl.created AS Created, obl.createdby AS CreatedBy, obl.updated AS Updated, obl.updatedby AS UpdatedBy, CAST('en_US' AS CHARACTER VARYING(6)) AS AD_Language, obl.description AS Description, obl.feature AS Feature, obl.m_product_id AS M_Product_ID, obl.backflushgroup AS BackflushGroup, obl.c_uom_id AS C_UOM_ID, obl.componenttype AS ComponentType, obl.datedelivered AS DateDelivered, obl.forecast AS Forecast, obl.help AS Help, obl.iscritical AS IsCritical, obl.issuemethod AS IssueMethod, obl.leadtimeoffset AS LeadTimeOffset, obl.line AS Line, obl.m_attributesetinstance_id AS M_AttributeSetInstance_ID, obl.m_changenotice_id AS M_ChangeNotice_ID, obl.m_locator_id AS M_Locator_ID, obl.m_warehouse_id AS M_Warehouse_ID, obl.pp_order_bom_id AS PP_Order_BOM_ID, obl.pp_order_bomline_id AS PP_Order_BOMLine_ID, obl.pp_order_id AS PP_Order_ID, obl.qtydelivered AS QtyDelivered, obl.qtypost AS QtyPost, obl.qtyreject AS QtyReject, obl.qtyscrap AS QtyScrap, obl.scrap AS Scrap, obl.validfrom AS ValidFrom, obl.validto AS ValidTo, obl.assay AS Assay, obl.ad_user_id AS AD_User_ID, round(obl.qtyrequiered, 4) AS QtyRequiered, round(bomqtyreserved(obl.m_product_id, obl.m_warehouse_id, 0), 4) AS QtyReserved, round(bomqtyavailable(obl.m_product_id, obl.m_warehouse_id, 0), 4) AS QtyAvailable, round(bomqtyonhand(obl.m_product_id, obl.m_warehouse_id, 0), 4) AS QtyOnHand, round(obl.qtybom, 4) AS QtyBOM, obl.isqtypercentage AS IsQtyPercentage, round(obl.qtybatch, 4) AS QtyBatch, CASE WHEN o.qtybatchs = 0 THEN 1 ELSE round(obl.qtyrequiered / o.qtybatchs, 4) END AS QtyBatchSize FROM pp_order_bomline obl JOIN pp_order o ON o.pp_order_id = obl.pp_order_id
;
-- Nov 28, 2021, 11:19:16 PM CET
CREATE OR REPLACE VIEW PP_Order_Node_v(AD_Client_ID, AD_Org_ID, IsActive, Created, CreatedBy, Updated, UpdatedBy, AD_Language, Name, C_BPartner_ID, Cost, DateFinish, DateFinishSchedule, DateStart, DateStartSchedule, Description, DocAction, DocStatus, Duration, DurationReal, DurationRequiered, Help, IsMilestone, IsSubcontracting, MovingTime, OverlapUnits, PP_Order_ID, PP_Order_Workflow_ID, PP_Order_Node_ID, Priority, QtyDelivered, QtyRequiered, QtyScrap, QueuingTime, S_Resource_ID, SetupTime, SetupTimeReal, UnitsCycles, ValidFrom, ValidTo, Value, WaitingTime, WorkingTime, Yield) AS SELECT onode.ad_client_id AS AD_Client_ID, onode.ad_org_id AS AD_Org_ID, onode.isactive AS IsActive, onode.created AS Created, onode.createdby AS CreatedBy, onode.updated AS Updated, onode.updatedby AS UpdatedBy, CAST('en_US' AS CHARACTER VARYING(6)) AS AD_Language, onode.name AS Name, onode.c_bpartner_id AS C_BPartner_ID, onode.cost AS Cost, onode.datefinish AS DateFinish, onode.datefinishschedule AS DateFinishSchedule, onode.datestart AS DateStart, onode.datestartschedule AS DateStartSchedule, onode.description AS Description, onode.docaction AS DocAction, onode.docstatus AS DocStatus, onode.duration AS Duration, onode.durationreal AS DurationReal, onode.durationrequiered AS DurationRequiered, onode.help AS Help, onode.ismilestone AS IsMilestone, onode.issubcontracting AS IsSubcontracting, onode.movingtime AS MovingTime, onode.overlapunits AS OverlapUnits, onode.pp_order_id AS PP_Order_ID, onode.pp_order_workflow_id AS PP_Order_Workflow_ID, onode.pp_order_node_id AS PP_Order_Node_ID, onode.priority AS Priority, onode.qtydelivered AS QtyDelivered, onode.qtyrequiered AS QtyRequiered, onode.qtyscrap AS QtyScrap, onode.queuingtime AS QueuingTime, onode.s_resource_id AS S_Resource_ID, onode.setuptime AS SetupTime, onode.setuptimereal AS SetupTimeReal, onode.unitscycles AS UnitsCycles, onode.validfrom AS ValidFrom, onode.validto AS ValidTo, onode.value AS Value, onode.waitingtime AS WaitingTime, onode.workingtime AS WorkingTime, onode.yield AS Yield FROM pp_order_node onode
;
-- Nov 28, 2021, 11:19:16 PM CET
CREATE OR REPLACE VIEW PP_Order_Workflow_Header_v(AD_Client_ID, AD_Org_ID, IsActive, Created, CreatedBy, Updated, UpdatedBy, AD_Language, PP_Order_ID, DocStatus, C_DocType_ID, Org_Location_ID, TaxID, M_Warehouse_ID, Warehouse_Location_ID, DocumentType, DocumentTypeNote, Planner_ID, SalesRep_Name, DateStart, DateStartSchedule, FloatAfter, FloatBefored, Line, Lot, SerNo, C_UOM_ID, S_Resource_ID, PP_Product_BOM_ID, AD_Workflow_ID, Assay, C_OrderLine_ID, PriorityRule, QtyBatchs, QtyDelivered, QtyEntered, QtyOrdered, DateConfirm, DateDelivered, DateFinish, DateFinishSchedule, DateOrdered, DatePromised, QtyReject, QtyReserved, QtyScrap, C_Campaign_ID, C_Project_ID, C_Activity_ID, Name, Description, Help, Author, Cost, DocumentNo, Duration, DurationUnit, Version, ValidFrom, ValidTo, MovingTime, OverlapUnits, PublishStatus, QueuingTime, SetupTime, UnitsCycles, WaitingTime, WorkflowType, WorkingTime, Yield, Logo_ID) AS SELECT o.ad_client_id AS AD_Client_ID, o.ad_org_id AS AD_Org_ID, o.isactive AS IsActive, o.created AS Created, o.createdby AS CreatedBy, o.updated AS Updated, o.updatedby AS UpdatedBy, CAST('en_US' AS CHARACTER VARYING(6)) AS AD_Language, o.pp_order_id AS PP_Order_ID, o.docstatus AS DocStatus, o.c_doctype_id AS C_DocType_ID, oi.c_location_id AS Org_Location_ID, oi.taxid AS TaxID, o.m_warehouse_id AS M_Warehouse_ID, wh.c_location_id AS Warehouse_Location_ID, d.printname AS DocumentType, d.documentnote AS DocumentTypeNote, o.planner_id AS Planner_ID, u.name AS SalesRep_Name, o.datestart AS DateStart, o.datestartschedule AS DateStartSchedule, o.floatafter AS FloatAfter, o.floatbefored AS FloatBefored, o.line AS Line, o.lot AS Lot, o.serno AS SerNo, o.c_uom_id AS C_UOM_ID, o.s_resource_id AS S_Resource_ID, o.pp_product_bom_id AS PP_Product_BOM_ID, o.ad_workflow_id AS AD_Workflow_ID, o.assay AS Assay, o.c_orderline_id AS C_OrderLine_ID, o.priorityrule AS PriorityRule, o.qtybatchs AS QtyBatchs, o.qtydelivered AS QtyDelivered, o.qtyentered AS QtyEntered, o.qtyordered AS QtyOrdered, o.dateconfirm AS DateConfirm, o.datedelivered AS DateDelivered, o.datefinish AS DateFinish, o.datefinishschedule AS DateFinishSchedule, o.dateordered AS DateOrdered, o.datepromised AS DatePromised, o.qtyreject AS QtyReject, o.qtyreserved AS QtyReserved, o.qtyscrap AS QtyScrap, o.c_campaign_id AS C_Campaign_ID, o.c_project_id AS C_Project_ID, o.c_activity_id AS C_Activity_ID, ow.name AS Name, ow.description AS Description, ow.help AS Help, ow.author AS Author, ow.cost AS Cost, ow.documentno AS DocumentNo, ow.duration AS Duration, ow.durationunit AS DurationUnit, ow.version AS Version, ow.validfrom AS ValidFrom, ow.validto AS ValidTo, ow.movingtime AS MovingTime, ow.overlapunits AS OverlapUnits, ow.publishstatus AS PublishStatus, ow.queuingtime AS QueuingTime, ow.setuptime AS SetupTime, ow.unitscycles AS UnitsCycles, ow.waitingtime AS WaitingTime, ow.workflowtype AS WorkflowType, ow.workingtime AS WorkingTime, ow.yield AS Yield, COALESCE(oi.logo_id, ci.logo_id) AS Logo_ID FROM pp_order o JOIN pp_order_workflow ow ON ow.pp_order_id = o.pp_order_id JOIN c_doctype d ON o.c_doctype_id = d.c_doctype_id JOIN m_warehouse wh ON o.m_warehouse_id = wh.m_warehouse_id JOIN ad_orginfo oi ON o.ad_org_id = oi.ad_org_id JOIN ad_clientinfo ci ON o.ad_client_id = ci.ad_client_id LEFT JOIN ad_user u ON o.planner_id = u.ad_user_id
;
-- Nov 28, 2021, 11:19:16 PM CET
CREATE OR REPLACE VIEW PP_Order_Header_v(AD_Client_ID, AD_Org_ID, IsActive, Created, CreatedBy, Updated, UpdatedBy, AD_Language, PP_Order_ID, DocumentNo, DocStatus, C_DocType_ID, Org_Location_ID, TaxID, M_Warehouse_ID, Warehouse_Location_ID, DocumentType, DocumentTypeNote, Planner_ID, SalesRep_Name, DateStart, DateStartSchedule, FloatAfter, FloatBefored, Line, Lot, SerNo, Description, M_Product_ID, M_AttributeSetInstance_ID, C_UOM_ID, S_Resource_ID, PP_Product_BOM_ID, AD_Workflow_ID, Assay, C_OrderLine_ID, PriorityRule, QtyBatchSize, QtyBatchs, QtyDelivered, QtyEntered, QtyOrdered, DateConfirm, DateDelivered, DateFinish, DateFinishSchedule, DateOrdered, DatePromised, QtyReject, QtyReserved, QtyScrap, Yield, C_Campaign_ID, C_Project_ID, C_Activity_ID, User1_ID, User2_ID, AD_OrgTrx_ID, C_DocTypeTarget_ID, ScheduleType, IsApproved, DocAction, Posted, IsPrinted, OrderType, Logo_ID) AS SELECT o.ad_client_id AS AD_Client_ID, o.ad_org_id AS AD_Org_ID, o.isactive AS IsActive, o.created AS Created, o.createdby AS CreatedBy, o.updated AS Updated, o.updatedby AS UpdatedBy, CAST('en_US' AS CHARACTER VARYING(6)) AS AD_Language, o.pp_order_id AS PP_Order_ID, o.documentno AS DocumentNo, o.docstatus AS DocStatus, o.c_doctype_id AS C_DocType_ID, oi.c_location_id AS Org_Location_ID, oi.taxid AS TaxID, o.m_warehouse_id AS M_Warehouse_ID, wh.c_location_id AS Warehouse_Location_ID, dt.printname AS DocumentType, dt.documentnote AS DocumentTypeNote, o.planner_id AS Planner_ID, u.name AS SalesRep_Name, o.datestart AS DateStart, o.datestartschedule AS DateStartSchedule, o.floatafter AS FloatAfter, o.floatbefored AS FloatBefored, o.line AS Line, o.lot AS Lot, o.serno AS SerNo, o.description AS Description, o.m_product_id AS M_Product_ID, o.m_attributesetinstance_id AS M_AttributeSetInstance_ID, o.c_uom_id AS C_UOM_ID, o.s_resource_id AS S_Resource_ID, o.pp_product_bom_id AS PP_Product_BOM_ID, o.ad_workflow_id AS AD_Workflow_ID, o.assay AS Assay, o.c_orderline_id AS C_OrderLine_ID, o.priorityrule AS PriorityRule, o.qtybatchsize AS QtyBatchSize, o.qtybatchs AS QtyBatchs, o.qtydelivered AS QtyDelivered, o.qtyentered AS QtyEntered, o.qtyordered AS QtyOrdered, o.dateconfirm AS DateConfirm, o.datedelivered AS DateDelivered, o.datefinish AS DateFinish, o.datefinishschedule AS DateFinishSchedule, o.dateordered AS DateOrdered, o.datepromised AS DatePromised, o.qtyreject AS QtyReject, o.qtyreserved AS QtyReserved, o.qtyscrap AS QtyScrap, o.yield AS Yield, o.c_campaign_id AS C_Campaign_ID, o.c_project_id AS C_Project_ID, o.c_activity_id AS C_Activity_ID, o.user1_id AS User1_ID, o.user2_id AS User2_ID, o.ad_orgtrx_id AS AD_OrgTrx_ID, o.c_doctypetarget_id AS C_DocTypeTarget_ID, o.scheduletype AS ScheduleType, o.isapproved AS IsApproved, o.docaction AS DocAction, o.posted AS Posted, o.isprinted AS IsPrinted, o.ordertype AS OrderType, COALESCE(oi.logo_id, ci.logo_id) AS Logo_ID FROM pp_order o JOIN c_doctype dt ON o.c_doctype_id = dt.c_doctype_id JOIN m_warehouse wh ON o.m_warehouse_id = wh.m_warehouse_id JOIN ad_orginfo oi ON o.ad_org_id = oi.ad_org_id JOIN ad_clientinfo ci ON o.ad_client_id = ci.ad_client_id LEFT JOIN ad_user u ON o.planner_id = u.ad_user_id
;
-- Nov 28, 2021, 11:19:16 PM CET
CREATE OR REPLACE VIEW RV_Storage_Per_Product(AD_Client_ID, AD_Org_ID, M_Product_ID, Value, Name, Description, UPC, SKU, C_UOM_ID, M_Product_Category_ID, Classification, Weight, Volume, VersionNo, GuaranteeDays, GuaranteeDaysMin, SumQtyOnHand) AS SELECT strg.ad_client_id AS AD_Client_ID, strg.ad_org_id AS AD_Org_ID, p.m_product_id AS M_Product_ID, p.value AS Value, p.name AS Name, p.description AS Description, p.upc AS UPC, p.sku AS SKU, p.c_uom_id AS C_UOM_ID, p.m_product_category_id AS M_Product_Category_ID, p.classification AS Classification, p.weight AS Weight, p.volume AS Volume, p.versionno AS VersionNo, p.guaranteedays AS GuaranteeDays, p.guaranteedaysmin AS GuaranteeDaysMin, strg.sumqtyonhand AS SumQtyOnHand FROM m_product p JOIN ( SELECT rv_storage.m_product_id, rv_storage.m_locator_id, sum(rv_storage.qtyonhand) AS sumqtyonhand, rv_storage.ad_client_id, rv_storage.ad_org_id FROM rv_storage GROUP BY rv_storage.m_product_id, rv_storage.m_locator_id, rv_storage.ad_client_id, rv_storage.ad_org_id) strg ON p.m_product_id = strg.m_product_id JOIN m_locator l ON strg.m_locator_id = l.m_locator_id
;
-- Nov 28, 2021, 11:19:16 PM CET
CREATE OR REPLACE VIEW RV_RequestUpdates_Only(AD_Client_ID, AD_Org_ID, IsActive, Created, CreatedBy, Updated, UpdatedBy, R_Request_ID, AD_User_ID) AS SELECT min(rv_requestupdates.ad_client_id) AS AD_Client_ID, min(rv_requestupdates.ad_org_id) AS AD_Org_ID, 'Y' AS IsActive, statement_timestamp() AS Created, 0 AS CreatedBy, statement_timestamp() AS Updated, 0 AS UpdatedBy, rv_requestupdates.r_request_id AS R_Request_ID, rv_requestupdates.ad_user_id AS AD_User_ID FROM rv_requestupdates WHERE rv_requestupdates.isactive = 'Y' GROUP BY rv_requestupdates.r_request_id, rv_requestupdates.ad_user_id
;
-- Nov 28, 2021, 11:19:16 PM CET
CREATE OR REPLACE VIEW RV_C_Invoice_ProdMonth(AD_Client_ID, AD_Org_ID, M_Product_Category_ID, DateInvoiced, LineNetAmt, LineListAmt, LineLimitAmt, LineDiscountAmt, LineDiscount, LineOverLimitAmt, LineOverLimit, QtyInvoiced, IsSOTrx) AS SELECT il.ad_client_id AS AD_Client_ID, il.ad_org_id AS AD_Org_ID, il.m_product_category_id AS M_Product_Category_ID, firstof(il.dateinvoiced, 'MM') AS DateInvoiced, sum(il.linenetamt) AS LineNetAmt, sum(il.linelistamt) AS LineListAmt, sum(il.linelimitamt) AS LineLimitAmt, sum(il.linediscountamt) AS LineDiscountAmt, CASE WHEN sum(il.linelistamt) = 0 THEN 0 ELSE currencyround((sum(il.linelistamt) - sum(il.linenetamt)) / sum(il.linelistamt) * 100, i.c_currency_id, 'N') END AS LineDiscount, sum(il.lineoverlimitamt) AS LineOverLimitAmt, CASE WHEN sum(il.linenetamt) = 0 THEN 0 ELSE 100 - currencyround((sum(il.linenetamt) - sum(il.lineoverlimitamt)) / sum(il.linenetamt) * 100, i.c_currency_id, 'N') END AS LineOverLimit, sum(il.qtyinvoiced) AS QtyInvoiced, il.issotrx AS IsSOTrx FROM rv_c_invoiceline il JOIN c_invoice i ON i.c_invoice_id = il.c_invoice_id GROUP BY il.ad_client_id, il.ad_org_id, il.m_product_category_id, (firstof(il.dateinvoiced, 'MM')), il.issotrx, i.c_currency_id
;
-- Nov 28, 2021, 11:19:16 PM CET
CREATE OR REPLACE VIEW RV_ProjectLineIssue(AD_Client_ID, AD_Org_ID, IsActive, Created, CreatedBy, Updated, UpdatedBy, C_Project_ID, M_Product_ID, C_ProjectLine_ID, Line, Description, PlannedQty, PlannedPrice, PlannedAmt, PlannedMarginAmt, CommittedQty, C_ProjectIssue_ID, M_Locator_ID, MovementQty, MovementDate, IssueLine, IssueDescription, M_InOutLine_ID, S_TimeExpenseLine_ID, C_AcctSchema_ID, Account_ID, AmtSourceDr, AmtSourceCr, AmtAcctDr, AmtAcctCr, LineMargin) AS SELECT COALESCE(l.ad_client_id, i.ad_client_id) AS AD_Client_ID, COALESCE(l.ad_org_id, i.ad_org_id) AS AD_Org_ID, COALESCE(l.isactive, i.isactive) AS IsActive, COALESCE(l.created, i.created) AS Created, COALESCE(l.createdby, i.createdby) AS CreatedBy, COALESCE(l.updated, i.updated) AS Updated, COALESCE(l.updatedby, i.updatedby) AS UpdatedBy, COALESCE(l.c_project_id, i.c_project_id) AS C_Project_ID, COALESCE(l.m_product_id, i.m_product_id) AS M_Product_ID, l.c_projectline_id AS C_ProjectLine_ID, l.line AS Line, l.description AS Description, l.plannedqty AS PlannedQty, l.plannedprice AS PlannedPrice, l.plannedamt AS PlannedAmt, l.plannedmarginamt AS PlannedMarginAmt, l.committedqty AS CommittedQty, i.c_projectissue_id AS C_ProjectIssue_ID, i.m_locator_id AS M_Locator_ID, i.movementqty AS MovementQty, i.movementdate AS MovementDate, i.line AS IssueLine, i.description AS IssueDescription, i.m_inoutline_id AS M_InOutLine_ID, i.s_timeexpenseline_id AS S_TimeExpenseLine_ID, fa.c_acctschema_id AS C_AcctSchema_ID, fa.account_id AS Account_ID, fa.amtsourcedr AS AmtSourceDr, fa.amtsourcecr AS AmtSourceCr, fa.amtacctdr AS AmtAcctDr, fa.amtacctcr AS AmtAcctCr, l.plannedamt - fa.amtsourcedr + fa.amtsourcecr AS LineMargin FROM c_projectline l FULL JOIN c_projectissue i ON i.c_project_id = l.c_project_id AND i.c_projectissue_id = l.c_projectissue_id LEFT JOIN fact_acct fa ON fa.ad_table_id = 623 AND fa.record_id = i.c_projectissue_id AND fa.m_locator_id IS NULL
;
-- Nov 28, 2021, 11:19:16 PM CET
CREATE OR REPLACE VIEW RV_Click_Unprocessed(W_Click_ID, AD_Client_ID, AD_Org_ID, IsActive, Created, CreatedBy, Updated, UpdatedBy, TargetURL, Referrer, Remote_Host, Remote_Addr, UserAgent, AcceptLanguage, Processed, W_ClickCount_ID, AD_User_ID, EMail) AS SELECT w_click.w_click_id AS W_Click_ID, w_click.ad_client_id AS AD_Client_ID, w_click.ad_org_id AS AD_Org_ID, w_click.isactive AS IsActive, w_click.created AS Created, w_click.createdby AS CreatedBy, w_click.updated AS Updated, w_click.updatedby AS UpdatedBy, w_click.targeturl AS TargetURL, w_click.referrer AS Referrer, w_click.remote_host AS Remote_Host, w_click.remote_addr AS Remote_Addr, w_click.useragent AS UserAgent, w_click.acceptlanguage AS AcceptLanguage, w_click.processed AS Processed, w_click.w_clickcount_id AS W_ClickCount_ID, w_click.ad_user_id AS AD_User_ID, w_click.email AS EMail FROM w_click WHERE w_click.w_clickcount_id IS NULL OR w_click.processed = 'N'
;
-- Nov 28, 2021, 11:19:16 PM CET
CREATE OR REPLACE VIEW C_PaySelection_Remittance_v(AD_Client_ID, AD_Org_ID, AD_Language, C_PaySelection_ID, C_PaySelectionLine_ID, C_PaySelectionCheck_ID, PaymentRule, Line, OpenAmt, PayAmt, DiscountAmt, DifferenceAmt, C_BPartner_ID, DocumentNo, DateInvoiced, GrandTotal, AmtInWords, C_Invoice_ID, c_payselectionline_created, C_PaySelectionLine_CreatedBy, c_payselectionline_description, c_payselectionline_isactive, IsManual, c_payselectionline_issotrx, Processed, c_payselectionline_updated, C_PaySelectionLine_UpdatedBy, C_Invoice_AD_Org_ID, AD_OrgTrx_ID, AD_User_ID, C_Activity_ID, C_BPartner_Location_ID, C_Campaign_ID, C_Charge_ID, C_ConversionType_ID, C_Currency_ID, C_DocType_ID, C_DocTypeTarget_ID, C_DunningLevel_ID, ChargeAmt, C_Payment_ID, C_PaymentTerm_ID, C_Project_ID, c_invoice_created, C_Invoice_CreatedBy, DateAcct, DateOrdered, DatePrinted, c_invoice_description, DocAction, DocStatus, DunningGrace, GenerateTo, InvoiceCollectionType, c_invoice_isactive, IsApproved, IsDiscountPrinted, IsInDispute, IsPayScheduleValid, IsPrinted, c_invoice_isselfservice, c_invoice_issotrx, IsTaxIncluded, IsTransferred, M_PriceList_ID, M_RMA_ID, c_invoice_paymentrule, POReference, Posted, ProcessedOn, Processing, Ref_Invoice_ID, Reversal_ID, SendEMail, TotalLines, c_invoice_updated, C_Invoice_UpdatedBy, User1_ID, User2_ID) AS SELECT psl.ad_client_id AS AD_Client_ID, psl.ad_org_id AS AD_Org_ID, CAST('en_US' AS CHARACTER VARYING(6)) AS AD_Language, psl.c_payselection_id AS C_PaySelection_ID, psl.c_payselectionline_id AS C_PaySelectionLine_ID, psl.c_payselectioncheck_id AS C_PaySelectionCheck_ID, psl.paymentrule AS PaymentRule, psl.line AS Line, psl.openamt AS OpenAmt, psl.payamt AS PayAmt, psl.discountamt AS DiscountAmt, psl.differenceamt AS DifferenceAmt, i.c_bpartner_id AS C_BPartner_ID, i.documentno AS DocumentNo, i.dateinvoiced AS DateInvoiced, i.grandtotal AS GrandTotal, i.grandtotal AS AmtInWords, psl.c_invoice_id AS C_Invoice_ID, psl.created AS c_payselectionline_created, psl.createdby AS C_PaySelectionLine_CreatedBy, psl.description AS c_payselectionline_description, psl.isactive AS c_payselectionline_isactive, psl.ismanual AS IsManual, psl.issotrx AS c_payselectionline_issotrx, psl.processed AS Processed, psl.updated AS c_payselectionline_updated, psl.updatedby AS C_PaySelectionLine_UpdatedBy, i.ad_org_id AS C_Invoice_AD_Org_ID, i.ad_orgtrx_id AS AD_OrgTrx_ID, i.ad_user_id AS AD_User_ID, i.c_activity_id AS C_Activity_ID, i.c_bpartner_location_id AS C_BPartner_Location_ID, i.c_campaign_id AS C_Campaign_ID, i.c_charge_id AS C_Charge_ID, i.c_conversiontype_id AS C_ConversionType_ID, i.c_currency_id AS C_Currency_ID, i.c_doctype_id AS C_DocType_ID, i.c_doctypetarget_id AS C_DocTypeTarget_ID, i.c_dunninglevel_id AS C_DunningLevel_ID, i.chargeamt AS ChargeAmt, i.c_payment_id AS C_Payment_ID, i.c_paymentterm_id AS C_PaymentTerm_ID, i.c_project_id AS C_Project_ID, i.created AS c_invoice_created, i.createdby AS C_Invoice_CreatedBy, i.dateacct AS DateAcct, i.dateordered AS DateOrdered, i.dateprinted AS DatePrinted, i.description AS c_invoice_description, i.docaction AS DocAction, i.docstatus AS DocStatus, i.dunninggrace AS DunningGrace, i.generateto AS GenerateTo, i.invoicecollectiontype AS InvoiceCollectionType, i.isactive AS c_invoice_isactive, i.isapproved AS IsApproved, i.isdiscountprinted AS IsDiscountPrinted, i.isindispute AS IsInDispute, i.ispayschedulevalid AS IsPayScheduleValid, i.isprinted AS IsPrinted, i.isselfservice AS c_invoice_isselfservice, i.issotrx AS c_invoice_issotrx, i.istaxincluded AS IsTaxIncluded, i.istransferred AS IsTransferred, i.m_pricelist_id AS M_PriceList_ID, i.m_rma_id AS M_RMA_ID, i.paymentrule AS c_invoice_paymentrule, i.poreference AS POReference, i.posted AS Posted, i.processedon AS ProcessedOn, i.processing AS Processing, i.ref_invoice_id AS Ref_Invoice_ID, i.reversal_id AS Reversal_ID, i.sendemail AS SendEMail, i.totallines AS TotalLines, i.updated AS c_invoice_updated, i.updatedby AS C_Invoice_UpdatedBy, i.user1_id AS User1_ID, i.user2_id AS User2_ID FROM c_payselectionline psl JOIN c_invoice i ON p
;
-- Nov 28, 2021, 11:19:16 PM CET
CREATE OR REPLACE VIEW RV_InOutConfirm(M_InOutConfirm_ID, AD_Client_ID, AD_Org_ID, IsActive, Created, CreatedBy, Updated, UpdatedBy, M_InOut_ID, DocumentNo, ConfirmType, IsApproved, IsCancelled, Description, Processing, Processed, C_BPartner_ID, C_BPartner_Location_ID, M_Warehouse_ID, C_Order_ID, IsSOTrx) AS SELECT c.m_inoutconfirm_id AS M_InOutConfirm_ID, c.ad_client_id AS AD_Client_ID, c.ad_org_id AS AD_Org_ID, c.isactive AS IsActive, c.created AS Created, c.createdby AS CreatedBy, c.updated AS Updated, c.updatedby AS UpdatedBy, c.m_inout_id AS M_InOut_ID, c.documentno AS DocumentNo, c.confirmtype AS ConfirmType, c.isapproved AS IsApproved, c.iscancelled AS IsCancelled, c.description AS Description, c.processing AS Processing, c.processed AS Processed, i.c_bpartner_id AS C_BPartner_ID, i.c_bpartner_location_id AS C_BPartner_Location_ID, i.m_warehouse_id AS M_Warehouse_ID, i.c_order_id AS C_Order_ID, i.issotrx AS IsSOTrx FROM m_inoutconfirm c JOIN m_inout i ON c.m_inout_id = i.m_inout_id
;
-- Nov 28, 2021, 11:19:16 PM CET
CREATE OR REPLACE VIEW RV_PrintFormatDetail(AD_Client_ID, AD_Org_ID, IsActive, Created, CreatedBy, Updated, UpdatedBy, AD_PrintFormat_ID, Name, Description, IsTableBased, IsForm, AD_Table_ID, AD_ReportView_ID, AD_PrintPaper_ID, Default_AD_PrintColor_ID, Default_AD_PrintFont_ID, IsStandardHeaderFooter, AD_PrintTableFormat_ID, HeaderMargin, FooterMargin, PrinterName, IsDefault, AD_PrintFormatItem_ID, ItemName, PrintName, PrintNameSuffix, IsPrinted, PrintAreaType, SeqNo, PrintFormatType, AD_Column_ID, AD_PrintFormatChild_ID, ImageIsAttached, ImageURL, IsRelativePosition, IsNextLine, XSpace, YSpace, XPosition, YPosition, MaxWidth, IsHeightOneLine, MaxHeight, IsFixedWidth, IsSetNLPosition, IsSuppressNull, BelowColumn, FieldAlignmentType, LineAlignmentType, AD_PrintColor_ID, AD_PrintFont_ID, IsOrderBy, SortNo, IsGroupBy, IsPageBreak, IsNextPage, IsSummarized, IsAveraged, IsCounted, IsMinCalc, IsMaxCalc, IsVarianceCalc, IsDeviationCalc, IsRunningTotal, RunningTotalLines, AD_PrintGraph_ID) AS SELECT f.ad_client_id AS AD_Client_ID, f.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, f.ad_printformat_id AS AD_PrintFormat_ID, f.name AS Name, f.description AS Description, f.istablebased AS IsTableBased, f.isform AS IsForm, f.ad_table_id AS AD_Table_ID, f.ad_reportview_id AS AD_ReportView_ID, f.ad_printpaper_id AS AD_PrintPaper_ID, f.ad_printcolor_id AS Default_AD_PrintColor_ID, f.ad_printfont_id AS Default_AD_PrintFont_ID, f.isstandardheaderfooter AS IsStandardHeaderFooter, f.ad_printtableformat_id AS AD_PrintTableFormat_ID, f.headermargin AS HeaderMargin, f.footermargin AS FooterMargin, f.printername AS PrinterName, f.isdefault AS IsDefault, i.ad_printformatitem_id AS AD_PrintFormatItem_ID, i.name AS ItemName, i.printname AS PrintName, i.printnamesuffix AS PrintNameSuffix, i.isprinted AS IsPrinted, i.printareatype AS PrintAreaType, i.seqno AS SeqNo, i.printformattype AS PrintFormatType, i.ad_column_id AS AD_Column_ID, i.ad_printformatchild_id AS AD_PrintFormatChild_ID, i.imageisattached AS ImageIsAttached, i.imageurl AS ImageURL, i.isrelativeposition AS IsRelativePosition, i.isnextline AS IsNextLine, i.xspace AS XSpace, i.yspace AS YSpace, i.xposition AS XPosition, i.yposition AS YPosition, i.maxwidth AS MaxWidth, i.isheightoneline AS IsHeightOneLine, i.maxheight AS MaxHeight, i.isfixedwidth AS IsFixedWidth, i.issetnlposition AS IsSetNLPosition, i.issuppressnull AS IsSuppressNull, i.belowcolumn AS BelowColumn, i.fieldalignmenttype AS FieldAlignmentType, i.linealignmenttype AS LineAlignmentType, i.ad_printcolor_id AS AD_PrintColor_ID, i.ad_printfont_id AS AD_PrintFont_ID, i.isorderby AS IsOrderBy, i.sortno AS SortNo, i.isgroupby AS IsGroupBy, i.ispagebreak AS IsPageBreak, i.isnextpage AS IsNextPage, i.issummarized AS IsSummarized, i.isaveraged AS IsAveraged, i.iscounted AS IsCounted, i.ismincalc AS IsMinCalc, i.ismaxcalc AS IsMaxCalc, i.isvariancecalc AS IsVarianceCalc, i.isdeviationcalc AS IsDeviationCalc, i.isrunningtotal AS IsRunningTotal, i.runningtotallines AS RunningTotalLines, i.ad_printgraph_id AS AD_PrintGraph_ID FROM ad_printformat f JOIN ad_printformatitem i ON f.ad_printformat_id = i.ad_printformat_id
;
-- Nov 28, 2021, 11:19:16 PM CET
CREATE OR REPLACE VIEW RV_InOutDetails(AD_Client_ID, AD_Org_ID, IsActive, Created, CreatedBy, Updated, UpdatedBy, M_InOut_ID, IsSOTrx, DocumentNo, DocAction, DocStatus, Posted, Processed, C_DocType_ID, Description, C_Order_ID, DateOrdered, MovementType, MovementDate, DateAcct, C_BPartner_ID, C_BPartner_Location_ID, AD_User_ID, SalesRep_ID, M_Warehouse_ID, POReference, DeliveryRule, FreightCostRule, FreightAmt, DeliveryViaRule, M_Shipper_ID, PriorityRule, DatePrinted, NoPackages, PickDate, ShipDate, TrackingNo, AD_OrgTrx_ID, C_Project_ID, C_Campaign_ID, C_Activity_ID, User1_ID, User2_ID, DateReceived, IsApproved, IsInDispute, M_InOutLine_ID, Line, LineDescription, C_OrderLine_ID, M_Locator_ID, M_Product_ID, C_UOM_ID, M_AttributeSetInstance_ID, ProductAttribute, M_AttributeSet_ID, M_Lot_ID, GuaranteeDate, Lot, SerNo, MovementQty, QtyEntered, IsDescription, ConfirmedQty, PickedQty, ScrappedQty, TargetQty, LocatorValue, X, Y, Z, M_InOut_C_Charge_ID, ChargeAmt, M_InOut_C_Invoice_ID, CreateConfirm, m_inout_created, M_InOut_CreatedBy, CreateFrom, CreatePackage, DropShip_BPartner_ID, DropShip_Location_ID, DropShip_User_ID, GenerateTo, m_inout_isactive, IsDropShip, IsInTransit, IsPrinted, M_RMA_ID, ProcessedOn, Processing, Ref_InOut_ID, Reversal_ID, SendEMail, m_inout_updated, M_InOut_UpdatedBy, Volume, Weight, M_InOutLine_AD_Org_ID, M_InOutLine_AD_OrgTrx_ID, M_InOutLine_C_Activity_ID, M_InOutLine_C_Campaign_ID, M_InOutLine_C_Charge_ID, M_InOutLine_C_Project_ID, C_ProjectPhase_ID, C_ProjectTask_ID, IsInvoiced, M_RMALine_ID, m_inoutline_processed, Ref_InOutLine_ID, ReversalLine_ID, M_InOutLine_User1_ID, M_InOutLine_User2_ID, M_Locator_AD_Org_ID, m_locator_isactive, IsDefault, M_Locator_M_Warehouse_ID, PriorityNo, M_ASI_AD_Org_ID, m_asi_created, M_ASI_CreatedBy, M_ASI_Description, m_asi_isactive, m_asi_updated, M_ASI_UpdatedBy) AS SELECT h.ad_client_id AS AD_Client_ID, h.ad_org_id AS AD_Org_ID, l.isactive AS IsActive, l.created AS Created, l.createdby AS CreatedBy, l.updated AS Updated, l.updatedby AS UpdatedBy, h.m_inout_id AS M_InOut_ID, h.issotrx AS IsSOTrx, h.documentno AS DocumentNo, h.docaction AS DocAction, h.docstatus AS DocStatus, h.posted AS Posted, h.processed AS Processed, h.c_doctype_id AS C_DocType_ID, h.description AS Description, h.c_order_id AS C_Order_ID, h.dateordered AS DateOrdered, h.movementtype AS MovementType, h.movementdate AS MovementDate, h.dateacct AS DateAcct, h.c_bpartner_id AS C_BPartner_ID, h.c_bpartner_location_id AS C_BPartner_Location_ID, h.ad_user_id AS AD_User_ID, h.salesrep_id AS SalesRep_ID, h.m_warehouse_id AS M_Warehouse_ID, h.poreference AS POReference, h.deliveryrule AS DeliveryRule, h.freightcostrule AS FreightCostRule, h.freightamt AS FreightAmt, h.deliveryviarule AS DeliveryViaRule, h.m_shipper_id AS M_Shipper_ID, h.priorityrule AS PriorityRule, h.dateprinted AS DatePrinted, h.nopackages AS NoPackages, h.pickdate AS PickDate, h.shipdate AS ShipDate, h.trackingno AS TrackingNo, h.ad_orgtrx_id AS AD_OrgTrx_ID, h.c_project_id AS C_Project_ID, h.c_campaign_id AS C_Campaign_ID, h.c_activity_id AS C_Activity_ID, h.user1_id AS User1_ID, h.user2_id AS User2_ID, h.datereceived AS DateReceived, h.isapproved AS IsApproved, h.isindispute AS IsInDispute, l.m_inoutline_id AS M_InOutLine_ID, l.line AS Line, l.description AS LineDescription, l.c_orderline_id AS C_OrderLine_ID, l.m_locator_id AS M_Locator_ID, l.m_product_id AS M_Product_ID, l.c_uom_id AS C_UOM_ID, l.m_attributesetinstance_id AS M_AttributeSetInstance_ID, productattribute(l.m_attributesetinstance_id) AS ProductAttribute, pasi.m_attributeset_id AS M_AttributeSet_ID, pasi.m_lot_id AS M_Lot_ID, pasi.guaranteedate AS GuaranteeDate, pasi.lot AS Lot, pasi.serno AS SerNo, l.movementqty AS MovementQty, l.qtyentered AS QtyEntered, l.isdescription AS IsDescription, l.confirmedqty AS ConfirmedQty, l.pickedqty AS PickedQty, l.scrappedqty AS ScrappedQty, l.targetqty AS TargetQty, loc.value AS LocatorValue, loc.x AS X, loc.y AS Y, loc.z AS Z, h.c_charge_id AS M_InOut_C_Charge_ID, h.chargeamt AS ChargeAmt, h.c_invoice_id AS M_InOut_C_Invoice_ID, h.cre
;
-- Nov 28, 2021, 11:19:16 PM CET
CREATE OR REPLACE VIEW C_Order_Header_v(AD_Client_ID, AD_Org_ID, IsActive, Created, CreatedBy, Updated, UpdatedBy, AD_Language, C_Order_ID, IsSOTrx, DocumentNo, DocStatus, C_DocType_ID, C_BPartner_ID, BPValue, BPTaxID, NAICS, DUNS, Org_Location_ID, TaxID, M_Warehouse_ID, Warehouse_Location_ID, DocumentType, DocumentTypeNote, SalesRep_ID, SalesRep_Name, DateOrdered, DatePromised, BPGreeting, Name, Name2, BPContactGreeting, Title, Phone, ContactName, C_Location_ID, Postal, ReferenceNo, Bill_BPartner_ID, Bill_Location_ID, Bill_User_ID, Bill_BPValue, Bill_BPTaxID, Bill_Name, Bill_Name2, Bill_Title, Bill_Phone, Bill_ContactName, Bill_C_Location_ID, Description, POReference, C_Currency_ID, PaymentTerm, PaymentTermNote, C_Charge_ID, ChargeAmt, TotalLines, GrandTotal, AmtInWords, M_PriceList_ID, IsTaxIncluded, Volume, Weight, C_Campaign_ID, C_Project_ID, C_Activity_ID, M_Shipper_ID, DeliveryRule, DeliveryViaRule, PriorityRule, InvoiceRule, Logo_ID, AD_OrgTrx_ID, AD_User_ID, AmountRefunded, AmountTendered, C_BPartner_Location_ID, C_CashLine_ID, C_CashPlanLine_ID, C_ConversionType_ID, C_DocTypeTarget_ID, CopyFrom, C_Payment_ID, C_PaymentTerm_ID, C_POS_ID, DateAcct, DatePrinted, DocAction, DropShip_BPartner_ID, DropShip_Location_ID, DropShip_User_ID, FreightAmt, FreightCostRule, IsApproved, IsCreditApproved, IsDelivered, IsDiscountPrinted, IsDropShip, IsInvoiced, IsPayScheduleValid, IsPrinted, IsSelected, IsSelfService, IsTransferred, Link_Order_ID, M_FreightCategory_ID, OrderType, Pay_BPartner_ID, Pay_Location_ID, PaymentRule, Posted, Processed, ProcessedOn, PromotionCode, Ref_Order_ID, SendEMail, User1_ID, User2_ID, M_Warehouse_AD_Org_ID, m_warehouse_description, m_warehouse_isactive, IsDisallowNegativeInv, IsInTransit, M_WarehouseSource_ID, m_warehouse_name, ReplenishmentClass, Separator, m_warehouse_value, C_PaymentTerm_AD_Org_ID, AfterDelivery, c_paymentterm_description, Discount, Discount2, DiscountDays, DiscountDays2, FixMonthCutoff, FixMonthDay, FixMonthOffset, GraceDays, c_paymentterm_isactive, IsDefault, IsDueFixed, IsNextBusinessDay, IsValid, NetDay, NetDays, PaymentTermUsage, m_paymentterm_value, bp_acqusitioncost, bp_actuallifetimevalue, bp_ad_language, BP_AD_OrgBP_ID, BP_AD_Org_ID, BP_BPartner_Parent_ID, BP_C_BP_Group_ID, BP_C_Dunning_ID, BP_C_Greeting_ID, BP_C_InvoiceSchedule_ID, BP_C_PaymentTerm_ID, bp_created, BP_CreatedBy, BP_C_TaxGroup_ID, bp_deliveryrule, bp_deliveryviarule, bp_description, bp_dunninggrace, bp_firstsale, bp_flatdiscount, bp_freightcostrule, bp_invoicerule, bp_isactive, bp_iscustomer, bp_isdiscountprinted, bp_isemployee, bp_ismanufacturer, bp_isonetime, bp_ispotaxexempt, bp_isprospect, bp_issalesrep, bp_issummary, bp_istaxexempt, bp_isvendor, BP_Logo_ID, BP_M_DiscountSchema_ID, BP_M_PriceList_ID, bp_numberemployees, bp_paymentrule, bp_paymentrulepo, BP_PO_DiscountSchema_ID, BP_PO_PaymentTerm_ID, BP_PO_PriceList_ID, bp_poreference, bp_potentiallifetimevalue, bp_rating, BP_SalesRep_ID, bp_salesvolume, bp_sendemail, bp_shareofcustomer, bp_shelflifeminpct, bp_so_creditlimit, bp_socreditstatus, bp_so_creditused, bp_so_description, bp_totalopenbalance, bp_updated, BP_UpdatedBy, bp_url, C_Greeting_AD_Org_ID, c_greeting_isactive, IsFirstNameOnly, c_greeting_name, BP_Location_AD_Org_ID, BP_Location_C_BPartner_ID, bp_location_created, BP_Location_CreatedBy, BP_Location_C_SalesRegion_ID, bp_location_fax, bp_location_isactive, bp_location_isbillto, bp_location_isdn, bp_location_ispayfrom, bp_location_isremitto, bp_location_isshipto, bp_location_name, bp_location_phone, bp_location_phone2, bp_location_updated, BP_Location_UpdatedBy, Address1, Address2, Address3, Address4, C_Location_AD_Org_ID, C_City_ID, C_Country_ID, City, c_location_created, C_Location_CreatedBy, C_Region_ID, c_location_isactive, RegionName, c_location_updated, C_Location_UpdatedBy, AD_User_AD_Org_ID, AD_User_AD_OrgTrx_ID, ad_user_ad_birthday, AD_User_C_BPartner_ID, AD_User_C_BPartner_Location_ID, AD_User_C_Greeting_ID, ad_user_comments, ad_user_created, AD_User_CreatedBy, ad_user_description, ad_user_email, ad_user_fax, ad_user_isactive,
;
-- Nov 28, 2021, 11:19:16 PM CET
CREATE OR REPLACE VIEW M_InOut_LineConfirm_v(AD_Client_ID, AD_Org_ID, IsActive, Created, CreatedBy, Updated, UpdatedBy, AD_Language, M_InOutLineConfirm_ID, M_InOutConfirm_ID, TargetQty, ConfirmedQty, DifferenceQty, ScrappedQty, Description, Processed, M_InOut_ID, M_InOutLine_ID, Line, M_Product_ID, MovementQty, UOMSymbol, QtyBackOrdered, Name, ShipDescription, DocumentNote, UPC, SKU, ProductValue, M_Locator_ID, M_Warehouse_ID, X, Y, Z, M_AttributeSetInstance_ID, M_AttributeSet_ID, SerNo, Lot, M_Lot_ID, GuaranteeDate) AS SELECT iolc.ad_client_id AS AD_Client_ID, iolc.ad_org_id AS AD_Org_ID, iolc.isactive AS IsActive, iolc.created AS Created, iolc.createdby AS CreatedBy, iolc.updated AS Updated, iolc.updatedby AS UpdatedBy, CAST('en_US' AS CHARACTER VARYING(6)) AS AD_Language, iolc.m_inoutlineconfirm_id AS M_InOutLineConfirm_ID, iolc.m_inoutconfirm_id AS M_InOutConfirm_ID, iolc.targetqty AS TargetQty, iolc.confirmedqty AS ConfirmedQty, iolc.differenceqty AS DifferenceQty, iolc.scrappedqty AS ScrappedQty, iolc.description AS Description, iolc.processed AS Processed, iol.m_inout_id AS M_InOut_ID, iol.m_inoutline_id AS M_InOutLine_ID, iol.line AS Line, p.m_product_id AS M_Product_ID, iol.movementqty AS MovementQty, uom.uomsymbol AS UOMSymbol, ol.qtyordered - ol.qtydelivered AS QtyBackOrdered, COALESCE(p.name, iol.description) AS Name, CASE WHEN p.name IS NOT NULL THEN iol.description ELSE NULL END AS ShipDescription, p.documentnote AS DocumentNote, p.upc AS UPC, p.sku AS SKU, p.value AS ProductValue, iol.m_locator_id AS M_Locator_ID, l.m_warehouse_id AS M_Warehouse_ID, l.x AS X, l.y AS Y, l.z AS Z, iol.m_attributesetinstance_id AS M_AttributeSetInstance_ID, asi.m_attributeset_id AS M_AttributeSet_ID, asi.serno AS SerNo, asi.lot AS Lot, asi.m_lot_id AS M_Lot_ID, asi.guaranteedate AS GuaranteeDate FROM m_inoutlineconfirm iolc JOIN m_inoutline iol ON iolc.m_inoutline_id = iol.m_inoutline_id JOIN c_uom uom ON iol.c_uom_id = uom.c_uom_id LEFT JOIN m_product p ON iol.m_product_id = p.m_product_id LEFT JOIN m_attributesetinstance asi ON iol.m_attributesetinstance_id = asi.m_attributesetinstance_id LEFT JOIN m_locator l ON iol.m_locator_id = l.m_locator_id LEFT JOIN c_orderline ol ON iol.c_orderline_id = ol.c_orderline_id
;
-- Nov 28, 2021, 11:19:16 PM CET
CREATE OR REPLACE VIEW RV_C_InvoiceTax(AD_Client_ID, AD_Org_ID, IsActive, Created, CreatedBy, Updated, UpdatedBy, C_Tax_ID, C_Invoice_ID, C_DocType_ID, C_BPartner_ID, TaxID, IsTaxExempt, DateAcct, DateInvoiced, IsSOTrx, DocumentNo, IsPaid, C_Currency_ID, TaxBaseAmt, TaxAmt, TaxLineTotal, Multiplier, C_InvoiceTax_AD_Org_ID, c_invoicetax_isactive, c_invoicetax_istaxincluded, c_invoicetax_processed, C_Invoice_AD_OrgTrx_ID, AD_User_ID, C_BPartner_Location_ID, C_Activity_ID, C_Campaign_ID, C_Charge_ID, C_ConversionType_ID, C_DocTypeTarget_ID, C_DunningLevel_ID, ChargeAmt, C_Order_ID, C_Payment_ID, C_Invoice_C_PaymentTerm_ID, c_invoice_created, C_Invoice_CreatedBy, DatePrinted, c_invoice_description, DocAction, DocStatus, DunningGrace, GenerateTo, InvoiceCollectionType, IsApproved, IsDiscountPrinted, IsInDispute, IsPayScheduleValid, IsPrinted, c_invoice_isselfservice, c_invoice_istaxincluded, IsTransferred, M_PriceList_ID, M_RMA_ID, PaymentRule, c_invoice_poreference, Posted, ProcessedOn, Processing, Ref_Invoice_ID, Reversal_ID, SalesRep_ID, SendEMail, TotalLines, c_invoice_updated, C_Invoice_UpdatedBy, User1_ID, User2_ID, c_bp_acqusitioncost, c_bp_actuallifetimevalue, c_bp_ad_language, C_BP_AD_OrgBP_ID, C_BP_AD_Org_ID, C_BP_BPartner_Parent_ID, C_BP_C_BP_Group_ID, C_BP_C_Dunning_ID, C_BP_C_Greeting_ID, C_BP_C_InvoiceSchedule_ID, C_BP_C_PaymentTerm_ID, c_bp_created, C_BP_CreatedBy, C_BP_C_TaxGroup_ID, c_bp_deliveryrule, c_bp_deliveryviarule, c_bp_description, c_bp_dunninggrace, DUNS, c_bp_firstsale, c_bp_flatdiscount, c_bp_freightcostrule, c_bp_invoicerule, c_bp_isactive, c_bp_iscustomer, c_bp_isdiscountprinted, c_bp_isemployee, c_bp_ismanufacturer, c_bp_isonetime, c_bp_ispotaxexempt, c_bp_isprospect, c_bp_issalesrep, c_bp_issummary, IsVendor, C_BP_Logo_ID, M_DiscountSchema_ID, C_BP_M_PriceList_ID, NAICS, c_bp_name, c_bp_name2, NumberEmployees, c_bp_paymentrule, c_bp_paymentrulepo, PO_DiscountSchema_ID, PO_PaymentTerm_ID, PO_PriceList_ID, c_bp_poreference, PotentialLifeTimeValue, c_bp_rating, C_BP_SalesRep_ID, SalesVolume, c_bp_sendemail, ShareOfCustomer, ShelfLifeMinPct, SO_CreditLimit, SOCreditStatus, SO_CreditUsed, SO_Description, c_bp_totalopenbalance, c_bp_updated, C_BP_UpdatedBy, c_bp_url, c_bp_value) AS SELECT i.ad_client_id AS AD_Client_ID, i.ad_org_id AS AD_Org_ID, i.isactive AS IsActive, t.created AS Created, t.createdby AS CreatedBy, t.updated AS Updated, t.updatedby AS UpdatedBy, t.c_tax_id AS C_Tax_ID, i.c_invoice_id AS C_Invoice_ID, i.c_doctype_id AS C_DocType_ID, i.c_bpartner_id AS C_BPartner_ID, bp.taxid AS TaxID, bp.istaxexempt AS IsTaxExempt, i.dateacct AS DateAcct, i.dateinvoiced AS DateInvoiced, i.issotrx AS IsSOTrx, i.documentno AS DocumentNo, i.ispaid AS IsPaid, i.c_currency_id AS C_Currency_ID, CASE WHEN charat(d.docbasetype, 3) = 'C' THEN t.taxbaseamt * '-1' ELSE t.taxbaseamt END AS TaxBaseAmt, CASE WHEN charat(d.docbasetype, 3) = 'C' THEN t.taxamt * '-1' ELSE t.taxamt END AS TaxAmt, CASE WHEN charat(d.docbasetype, 3) = 'C' THEN (t.taxbaseamt + t.taxamt) * '-1' ELSE t.taxbaseamt + t.taxamt END AS TaxLineTotal, CASE WHEN charat(d.docbasetype, 3) = 'C' THEN -1 ELSE 1 END AS Multiplier, t.ad_org_id AS C_InvoiceTax_AD_Org_ID, t.isactive AS c_invoicetax_isactive, t.istaxincluded AS c_invoicetax_istaxincluded, t.processed AS c_invoicetax_processed, i.ad_orgtrx_id AS C_Invoice_AD_OrgTrx_ID, i.ad_user_id AS AD_User_ID, i.c_bpartner_location_id AS C_BPartner_Location_ID, i.c_activity_id AS C_Activity_ID, i.c_campaign_id AS C_Campaign_ID, i.c_charge_id AS C_Charge_ID, i.c_conversiontype_id AS C_ConversionType_ID, i.c_doctypetarget_id AS C_DocTypeTarget_ID, i.c_dunninglevel_id AS C_DunningLevel_ID, i.chargeamt AS ChargeAmt, i.c_order_id AS C_Order_ID, i.c_payment_id AS C_Payment_ID, i.c_paymentterm_id AS C_Invoice_C_PaymentTerm_ID, i.created AS c_invoice_created, i.createdby AS C_Invoice_CreatedBy, i.dateprinted AS DatePrinted, i.description AS c_invoice_description, i.docaction AS DocAction, i.docstatus AS DocStatus, i.dunninggrace AS DunningGrace, i.generateto AS GenerateTo, i.invoicecollectiontype AS InvoiceCol
;
-- Nov 28, 2021, 11:19:16 PM CET
CREATE OR REPLACE VIEW RV_Fact_Acct_Period(AD_Client_ID, AD_Org_ID, C_AcctSchema_ID, Account_ID, C_Period_ID, GL_Category_ID, GL_Budget_ID, C_Tax_ID, M_Locator_ID, PostingType, C_Currency_ID, AmtSourceDr, AmtSourceCr, AmtSource, AmtAcctDr, AmtAcctCr, AmtAcct, Rate, M_Product_ID, C_BPartner_ID, AD_OrgTrx_ID, C_LocFrom_ID, C_LocTo_ID, C_SalesRegion_ID, C_Project_ID, C_Campaign_ID, C_Activity_ID, User1_ID, User2_ID, A_Asset_ID) AS SELECT fact_acct.ad_client_id AS AD_Client_ID, fact_acct.ad_org_id AS AD_Org_ID, fact_acct.c_acctschema_id AS C_AcctSchema_ID, fact_acct.account_id AS Account_ID, fact_acct.c_period_id AS C_Period_ID, fact_acct.gl_category_id AS GL_Category_ID, fact_acct.gl_budget_id AS GL_Budget_ID, fact_acct.c_tax_id AS C_Tax_ID, fact_acct.m_locator_id AS M_Locator_ID, fact_acct.postingtype AS PostingType, fact_acct.c_currency_id AS C_Currency_ID, sum(fact_acct.amtsourcedr) AS AmtSourceDr, sum(fact_acct.amtsourcecr) AS AmtSourceCr, sum(fact_acct.amtsourcedr - fact_acct.amtsourcecr) AS AmtSource, sum(fact_acct.amtacctdr) AS AmtAcctDr, sum(fact_acct.amtacctcr) AS AmtAcctCr, sum(fact_acct.amtacctdr - fact_acct.amtacctcr) AS AmtAcct, CASE WHEN sum(fact_acct.amtsourcedr - fact_acct.amtsourcecr) = 0 THEN 0 ELSE sum(fact_acct.amtacctdr - fact_acct.amtacctcr) / sum(fact_acct.amtsourcedr - fact_acct.amtsourcecr) END AS Rate, fact_acct.m_product_id AS M_Product_ID, fact_acct.c_bpartner_id AS C_BPartner_ID, fact_acct.ad_orgtrx_id AS AD_OrgTrx_ID, fact_acct.c_locfrom_id AS C_LocFrom_ID, fact_acct.c_locto_id AS C_LocTo_ID, fact_acct.c_salesregion_id AS C_SalesRegion_ID, fact_acct.c_project_id AS C_Project_ID, fact_acct.c_campaign_id AS C_Campaign_ID, fact_acct.c_activity_id AS C_Activity_ID, fact_acct.user1_id AS User1_ID, fact_acct.user2_id AS User2_ID, fact_acct.a_asset_id AS A_Asset_ID FROM fact_acct GROUP BY fact_acct.ad_client_id, fact_acct.ad_org_id, fact_acct.c_acctschema_id, fact_acct.account_id, fact_acct.c_period_id, fact_acct.gl_category_id, fact_acct.gl_budget_id, fact_acct.c_tax_id, fact_acct.m_locator_id, fact_acct.postingtype, fact_acct.c_currency_id, fact_acct.m_product_id, fact_acct.c_bpartner_id, fact_acct.ad_orgtrx_id, fact_acct.c_locfrom_id, fact_acct.c_locto_id, fact_acct.c_salesregion_id, fact_acct.c_project_id, fact_acct.c_campaign_id, fact_acct.c_activity_id, fact_acct.user1_id, fact_acct.user2_id, fact_acct.a_asset_id
;
-- Nov 28, 2021, 11:19:16 PM CET
CREATE OR REPLACE VIEW RV_PP_Operation_Activity(AD_Client_ID, AD_Org_ID, Created, CreatedBy, IsActive, Updated, UpdatedBy, PP_Order_ID, DocStatus, Value, S_Resource_ID, DurationRequiered, DurationReal, Duration, QtyDelivered, QtyReject, QtyScrap, DateStartSchedule, DateFinishSchedule) AS SELECT n.ad_client_id AS AD_Client_ID, n.ad_org_id AS AD_Org_ID, n.created AS Created, n.createdby AS CreatedBy, n.isactive AS IsActive, n.updated AS Updated, n.updatedby AS UpdatedBy, n.pp_order_id AS PP_Order_ID, n.docstatus AS DocStatus, n.value AS Value, n.s_resource_id AS S_Resource_ID, n.durationrequiered AS DurationRequiered, n.durationreal AS DurationReal, n.durationrequiered - n.durationreal AS Duration, n.qtydelivered AS QtyDelivered, n.qtyreject AS QtyReject, n.qtyscrap AS QtyScrap, n.datestartschedule AS DateStartSchedule, n.datefinishschedule AS DateFinishSchedule FROM pp_order_node n
;
-- Nov 28, 2021, 11:19:16 PM CET
CREATE OR REPLACE VIEW RV_PP_MRP(PP_MRP_ID, AD_Client_ID, AD_Org_ID, Created, CreatedBy, IsActive, IsAvailable, Updated, UpdatedBy, IsMPS, Name, Description, C_Order_ID, C_OrderLine_ID, DateOrdered, DateConfirm, DatePromised, DateStartSchedule, DateFinishSchedule, DateStart, DateSimulation, DocStatus, M_Forecast_ID, M_ForecastLine_ID, Value, M_Product_ID, M_Requisition_ID, M_RequisitionLine_ID, M_Warehouse_ID, PP_Order_ID, PP_Order_BOMLine_ID, DD_Order_ID, DD_OrderLine_ID, Qty, S_Resource_ID, Planner_ID, Priority, OrderType, TypeMRP, LowLevel, C_BPartner_ID, Version, DocumentNo) AS SELECT mrp.pp_mrp_id AS PP_MRP_ID, mrp.ad_client_id AS AD_Client_ID, mrp.ad_org_id AS AD_Org_ID, mrp.created AS Created, mrp.createdby AS CreatedBy, mrp.isactive AS IsActive, mrp.isavailable AS IsAvailable, mrp.updated AS Updated, mrp.updatedby AS UpdatedBy, pp.ismps AS IsMPS, mrp.name AS Name, mrp.description AS Description, mrp.c_order_id AS C_Order_ID, mrp.c_orderline_id AS C_OrderLine_ID, mrp.dateordered AS DateOrdered, mrp.dateconfirm AS DateConfirm, mrp.datepromised AS DatePromised, mrp.datestartschedule AS DateStartSchedule, mrp.datefinishschedule AS DateFinishSchedule, mrp.datestart AS DateStart, mrp.datesimulation AS DateSimulation, mrp.docstatus AS DocStatus, mrp.m_forecast_id AS M_Forecast_ID, mrp.m_forecastline_id AS M_ForecastLine_ID, mrp.value AS Value, mrp.m_product_id AS M_Product_ID, mrp.m_requisition_id AS M_Requisition_ID, mrp.m_requisitionline_id AS M_RequisitionLine_ID, mrp.m_warehouse_id AS M_Warehouse_ID, mrp.pp_order_id AS PP_Order_ID, mrp.pp_order_bomline_id AS PP_Order_BOMLine_ID, mrp.dd_order_id AS DD_Order_ID, mrp.dd_orderline_id AS DD_OrderLine_ID, mrp.qty AS Qty, mrp.s_resource_id AS S_Resource_ID, mrp.planner_id AS Planner_ID, mrp.priority AS Priority, mrp.ordertype AS OrderType, mrp.typemrp AS TypeMRP, p.lowlevel AS LowLevel, mrp.c_bpartner_id AS C_BPartner_ID, mrp.version AS Version, documentno(mrp.pp_mrp_id) AS DocumentNo FROM pp_mrp mrp JOIN m_product p ON mrp.m_product_id = p.m_product_id LEFT JOIN pp_product_planning pp ON pp.m_product_id = mrp.m_product_id AND mrp.m_warehouse_id = pp.m_warehouse_id WHERE mrp.qty <> 0 UNION SELECT 0 AS PP_MRP_ID, pp.ad_client_id AS AD_Client_ID, pp.ad_org_id AS AD_Org_ID, pp.created AS Created, pp.createdby AS CreatedBy, pp.isactive AS IsActive, 'Y' AS IsAvailable, pp.updated AS Updated, pp.updatedby AS UpdatedBy, pp.ismps AS IsMPS, NULL AS Name, NULL AS Description, NULL AS C_Order_ID, NULL AS C_OrderLine_ID, getdate() AS DateOrdered, getdate() AS DateConfirm, getdate() AS DatePromised, getdate() AS DateStartSchedule, getdate() AS DateFinishSchedule, getdate() AS DateStart, getdate() AS DateSimulation, 'CO' AS DocStatus, NULL AS M_Forecast_ID, NULL AS M_ForecastLine_ID, NULL AS Value, pp.m_product_id AS M_Product_ID, NULL AS M_Requisition_ID, NULL AS M_RequisitionLine_ID, pp.m_warehouse_id AS M_Warehouse_ID, NULL AS PP_Order_ID, NULL AS PP_Order_BOMLine_ID, NULL AS DD_Order_ID, NULL AS DD_OrderLine_ID, pp.safetystock - bomqtyonhand(pp.m_product_id, pp.m_warehouse_id, 0) AS Qty, pp.s_resource_id AS S_Resource_ID, NULL AS Planner_ID, NULL AS Priority, 'STK' AS OrderType, 'D' AS TypeMRP, p.lowlevel AS LowLevel, NULL AS C_BPartner_ID, NULL AS Version, 'Safety Strock' AS DocumentNo FROM pp_product_planning pp JOIN m_product p ON pp.m_product_id = p.m_product_id WHERE bomqtyonhand(pp.m_product_id, pp.m_warehouse_id, 0) < pp.safetystock
;
-- Nov 28, 2021, 11:19:16 PM CET
CREATE OR REPLACE VIEW M_CostMovement_v(AD_Client_ID, AD_Org_ID, C_AcctSchema_ID, M_CostHistory_ID, M_CostType_ID, M_CostElement_ID, M_AttributeSetInstance_ID, M_Product_ID, OldQty, NewQty, OldCostPrice, NewCostPrice, OldCQty, NewCQty, OldCAmt, NewCAmt, Qty, Amt, DeltaQty, DeltaAmt, C_OrderLine_ID, M_InOutLine_ID, C_InvoiceLine_ID, M_MovementLine_ID, M_InventoryLine_ID, M_ProductionLine_ID, C_ProjectIssue_ID, M_MatchInv_ID, M_CostDetail_ID, Description, Created, CreatedBy, Updated, UpdatedBy, IsActive) AS SELECT a.ad_client_id AS AD_Client_ID, a.ad_org_id AS AD_Org_ID, b.c_acctschema_id AS C_AcctSchema_ID, a.m_costhistory_id AS M_CostHistory_ID, a.m_costtype_id AS M_CostType_ID, a.m_costelement_id AS M_CostElement_ID, a.m_attributesetinstance_id AS M_AttributeSetInstance_ID, b.m_product_id AS M_Product_ID, a.oldqty AS OldQty, a.newqty AS NewQty, a.oldcostprice AS OldCostPrice, a.newcostprice AS NewCostPrice, a.oldcqty AS OldCQty, a.newcqty AS NewCQty, a.oldcamt AS OldCAmt, a.newcamt AS NewCAmt, b.qty AS Qty, b.amt AS Amt, b.deltaqty AS DeltaQty, b.deltaamt AS DeltaAmt, b.c_orderline_id AS C_OrderLine_ID, b.m_inoutline_id AS M_InOutLine_ID, b.c_invoiceline_id AS C_InvoiceLine_ID, b.m_movementline_id AS M_MovementLine_ID, b.m_inventoryline_id AS M_InventoryLine_ID, b.m_productionline_id AS M_ProductionLine_ID, b.c_projectissue_id AS C_ProjectIssue_ID, b.m_matchinv_id AS M_MatchInv_ID, a.m_costdetail_id AS M_CostDetail_ID, b.description AS Description, a.created AS Created, a.createdby AS CreatedBy, a.updated AS Updated, a.updatedby AS UpdatedBy, a.isactive AS IsActive FROM m_costhistory a JOIN m_costdetail b ON a.m_costdetail_id = b.m_costdetail_id ORDER BY a.m_costhistory_id
;
-- Nov 28, 2021, 11:19:16 PM CET
CREATE OR REPLACE VIEW T_RV_Reconciliation(AD_Client_ID, AD_Org_ID, IsActive, Created, CreatedBy, Updated, UpdatedBy, Fact_Acct_ID, C_AcctSchema_ID, Account_ID, DateTrx, DateAcct, C_Period_ID, AD_Table_ID, Record_ID, Line_ID, GL_Category_ID, GL_Budget_ID, C_Tax_ID, M_Locator_ID, PostingType, C_Currency_ID, AmtSourceDr, AmtSourceCr, AmtSource, AmtAcctDr, AmtAcctCr, AmtAcct, Rate, C_UOM_ID, Qty, M_Product_ID, C_BPartner_ID, AD_OrgTrx_ID, C_LocFrom_ID, C_LocTo_ID, C_SalesRegion_ID, C_Project_ID, C_Campaign_ID, C_Activity_ID, User1_ID, User2_ID, A_Asset_ID, Description, OrgValue, OrgName, AccountValue, Name, AccountType, BPartnerValue, BPName, C_BP_Group_ID, ProductValue, ProductName, UPC, M_Product_Category_ID, C_ProjectPhase_ID, C_ProjectTask_ID, C_SubAcct_ID, UserElement1_ID, UserElement2_ID, ad_org_description, ad_org_isactive, C_ElementValue_AD_Org_ID, C_BankAccount_ID, C_ElementValue_C_Currency_ID, C_Element_ID, C_ElementValue_ID, c_elementvalue_description, c_elementvalue_isactive, IsBankAccount, IsForeignCurrency, c_elementvalue_issummary, c_bp_acqusitioncost, c_bp_actuallifetimevalue, c_bp_ad_language, C_BP_AD_OrgBP_ID, C_BP_AD_Org_ID, C_BP_BPartner_Parent_ID, C_BP_C_Dunning_ID, C_BP_C_Greeting_ID, C_BP_C_InvoiceSchedule_ID, C_BP_C_PaymentTerm_ID, c_bp_created, C_BP_CreatedBy, C_BP_C_TaxGroup_ID, c_bp_deliveryrule, c_bp_deliveryviarule, c_bp_description, c_bp_dunninggrace, DUNS, c_bp_firstsale, c_bp_flatdiscount, c_bp_freightcostrule, c_bp_invoicerule, c_bp_isactive, c_bp_iscustomer, c_bp_isdiscountprinted, c_bp_isemployee, c_bp_ismanufacturer, c_bp_isonetime, c_bp_ispotaxexempt, c_bp_isprospect, c_bp_issalesrep, c_bp_issummary, c_bp_istaxexempt, c_bp_isvendor, C_BP_Logo_ID, C_BP_M_DiscountSchema_ID, C_BP_M_PriceList_ID, NAICS, c_bp_name2, c_bp_numberemployees, c_bp_paymentrule, c_bp_paymentrulepo, C_BP_PO_DiscountSchema_ID, C_BP_PO_PaymentTerm_ID, C_BP_PO_PriceList_ID, c_bp_poreference, c_bp_potentiallifetimevalue, c_bp_rating, ReferenceNo, C_BP_SalesRep_ID, c_bp_salesvolume, c_bp_sendemail, c_bp_shareofcustomer, c_bp_shelflifeminpct, c_bp_so_creditlimit, c_bp_socreditstatus, c_bp_so_creditused, c_bp_so_description, TaxID, c_bp_totalopenbalance, c_bp_updated, C_BP_UpdatedBy, c_bp_url, 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, m_product_description, DescriptionURL, Discontinued, DiscontinuedAt, DocumentNote, Group1, Group2, GuaranteeDays, GuaranteeDaysMin, Help, ImageURL, m_product_isactive, IsDropShip, IsExcludeAutoDelivery, IsInvoicePrintDetails, IsPickListPrintDetails, IsPurchased, IsSelfService, IsSold, IsStocked, m_product_issummary, IsVerified, IsWebStoreFeatured, LowLevel, M_Product_M_AttributeSet_ID, M_Product_M_ASI_ID, M_FreightCategory_ID, M_Product_M_Locator_ID, m_product_processing, ProductType, R_MailText_ID, M_Product_SalesRep_ID, S_ExpenseType_ID, ShelfDepth, ShelfHeight, ShelfWidth, SKU, S_Resource_ID, UnitsPerPack, UnitsPerPallet, m_product_updated, M_Product_UpdatedBy, VersionNo, Volume, Weight, AD_PInstance_ID, MatchCode) AS SELECT f.ad_client_id AS AD_Client_ID, f.ad_org_id AS AD_Org_ID, f.isactive AS IsActive, f.created AS Created, f.createdby AS CreatedBy, f.updated AS Updated, f.updatedby AS UpdatedBy, f.fact_acct_id AS Fact_Acct_ID, f.c_acctschema_id AS C_AcctSchema_ID, f.account_id AS Account_ID, f.datetrx AS DateTrx, f.dateacct AS DateAcct, f.c_period_id AS C_Period_ID, f.ad_table_id AS AD_Table_ID, f.record_id AS Record_ID, f.line_id AS Line_ID, f.gl_category_id AS GL_Category_ID, f.gl_budget_id AS GL_Budget_ID, f.c_tax_id AS C_Tax_ID, f.m_locator_id AS M_Locator_ID, f.postingtype AS PostingType, f.c_currency_id AS C_Currency_ID, f.amtsourcedr AS AmtSourceDr, f.amtsourcecr AS AmtSourceCr, f.amtsource AS AmtSource, f.amtacctdr AS AmtAcctDr, f.amtacctcr AS AmtAcctCr, f.amtacct AS AmtAcct, f.rate AS Rate, f.c_uom_id AS C_UOM_ID, f.qty AS Qty, f.m_product_id AS M_Product_ID, f.c_bpartner_id AS C_BPartner_ID, f.ad_orgtrx_id AS AD_OrgTrx_ID, f.c_locfrom_id
;
-- Nov 28, 2021, 11:19:16 PM CET
CREATE OR REPLACE VIEW M_Storage(M_Product_ID, M_Locator_ID, AD_Client_ID, AD_Org_ID, IsActive, Created, CreatedBy, Updated, UpdatedBy, QtyOnHand, QtyReserved, QtyOrdered, DateLastInventory, M_AttributeSetInstance_ID, M_Storage_UU, DateMaterialPolicy) AS SELECT s.m_product_id AS M_Product_ID, s.m_locator_id AS M_Locator_ID, s.ad_client_id AS AD_Client_ID, s.ad_org_id AS AD_Org_ID, s.isactive AS IsActive, s.created AS Created, s.createdby AS CreatedBy, s.updated AS Updated, s.updatedby AS UpdatedBy, s.qtyonhand AS QtyOnHand, 0 AS QtyReserved, 0 AS QtyOrdered, s.datelastinventory AS DateLastInventory, s.m_attributesetinstance_id AS M_AttributeSetInstance_ID, s.m_storageonhand_uu AS M_Storage_UU, s.datematerialpolicy AS DateMaterialPolicy FROM m_storageonhand s UNION ALL SELECT sr.m_product_id AS M_Product_ID, w.m_reservelocator_id AS M_Locator_ID, sr.ad_client_id AS AD_Client_ID, sr.ad_org_id AS AD_Org_ID, sr.isactive AS IsActive, sr.created AS Created, sr.createdby AS CreatedBy, sr.updated AS Updated, sr.updatedby AS UpdatedBy, 0 AS QtyOnHand, sr.qty AS QtyReserved, 0 AS QtyOrdered, sr.datelastinventory AS DateLastInventory, sr.m_attributesetinstance_id AS M_AttributeSetInstance_ID, sr.m_storagereservation_uu AS M_Storage_UU, NULL AS DateMaterialPolicy FROM m_storagereservation sr JOIN m_warehouse w ON sr.m_warehouse_id = w.m_warehouse_id WHERE sr.issotrx = 'Y' AND sr.qty <> 0 UNION ALL SELECT so.m_product_id AS M_Product_ID, w.m_reservelocator_id AS M_Locator_ID, so.ad_client_id AS AD_Client_ID, so.ad_org_id AS AD_Org_ID, so.isactive AS IsActive, so.created AS Created, so.createdby AS CreatedBy, so.updated AS Updated, so.updatedby AS UpdatedBy, 0 AS QtyOnHand, 0 AS QtyReserved, so.qty AS QtyOrdered, so.datelastinventory AS DateLastInventory, so.m_attributesetinstance_id AS M_AttributeSetInstance_ID, so.m_storagereservation_uu AS M_Storage_UU, NULL AS DateMaterialPolicy FROM m_storagereservation so JOIN m_warehouse w ON so.m_warehouse_id = w.m_warehouse_id WHERE so.issotrx = 'N' AND so.qty <> 0
;
-- Nov 28, 2021, 11:19:16 PM CET
CREATE OR REPLACE VIEW RV_T_1099Extract(AD_PInstance_ID, AD_Client_ID, AD_Org_ID, IsActive, Created, CreatedBy, Updated, UpdatedBy, C_BPartner_ID, Value, Name, TaxID, Address, Address1, Address2, Address3, Address4, CityStateZip, City, Region, Zip, Country, Cut_Year, Cut_Date, AmtBucket01, AmtBucket02, AmtBucket03, AmtBucket04, AmtBucket05, AmtBucket06, AmtBucket07, AmtBucket08, AmtBucket09, AmtBucket10, AmtBucket11, AmtBucket12, AmtBucket13, AmtBucket14, AmtBucket15, AmtBucket16) AS SELECT t.ad_pinstance_id AS AD_PInstance_ID, t.ad_client_id AS AD_Client_ID, t.ad_org_id AS AD_Org_ID, t.isactive AS IsActive, t.created AS Created, t.createdby AS CreatedBy, t.updated AS Updated, t.updatedby AS UpdatedBy, t.c_bpartner_id AS C_BPartner_ID, t.value AS Value, t.name AS Name, t.taxid AS TaxID, (((((l.address1 || ' ') || l.address2) || ' ') || l.address3) || ' ') || l.address4 AS Address, l.address1 AS Address1, l.address2 AS Address2, l.address3 AS Address3, l.address4 AS Address4, (((l.city || ', ') || r.name) || ' ') || l.postal AS CityStateZip, l.city AS City, r.name AS Region, l.postal AS Zip, ctry.name AS Country, t.cut_year AS Cut_Year, t.cut_date AS Cut_Date, COALESCE(t.amtbucket01, 0) AS AmtBucket01, COALESCE(t.amtbucket02, 0) AS AmtBucket02, COALESCE(t.amtbucket03, 0) AS AmtBucket03, COALESCE(t.amtbucket04, 0) AS AmtBucket04, COALESCE(t.amtbucket05, 0) AS AmtBucket05, COALESCE(t.amtbucket06, 0) AS AmtBucket06, COALESCE(t.amtbucket07, 0) AS AmtBucket07, COALESCE(t.amtbucket08, 0) AS AmtBucket08, COALESCE(t.amtbucket09, 0) AS AmtBucket09, COALESCE(t.amtbucket10, 0) AS AmtBucket10, COALESCE(t.amtbucket11, 0) AS AmtBucket11, COALESCE(t.amtbucket12, 0) AS AmtBucket12, COALESCE(t.amtbucket13, 0) AS AmtBucket13, COALESCE(t.amtbucket14, 0) AS AmtBucket14, COALESCE(t.amtbucket15, 0) AS AmtBucket15, COALESCE(t.amtbucket16, 0) AS AmtBucket16 FROM t_1099extract t LEFT JOIN c_location l ON t.c_location_id = l.c_location_id LEFT JOIN c_region r ON r.c_region_id = l.c_region_id LEFT JOIN c_country ctry ON ctry.c_country_id = l.c_country_id WHERE t.ad_pinstance_id = (( SELECT max(t_1099extract.ad_pinstance_id) AS max FROM t_1099extract))
;
-- Nov 28, 2021, 11:19:16 PM CET
CREATE OR REPLACE VIEW RV_M_Product_WhereUsed_V(AD_Client_ID, AD_Org_ID, M_Product_ID, SelectedProductName, SelectedProductValue, SelectedProductDescription, PP_Product_BOM_ID, Value, Name, Description, QtyBOM, Line) AS SELECT bom.ad_client_id AS AD_Client_ID, bom.ad_org_id AS AD_Org_ID, p2.m_product_id AS M_Product_ID, p2.name AS SelectedProductName, p2.value AS SelectedProductValue, p2.description AS SelectedProductDescription, b.pp_product_bom_id AS PP_Product_BOM_ID, p.value AS Value, p.name AS Name, p.description AS Description, b.qtybom AS QtyBOM, b.line AS Line FROM m_product p2 LEFT JOIN pp_product_bomline b ON p2.m_product_id = b.m_product_id LEFT JOIN pp_product_bom bom ON b.pp_product_bom_id = bom.pp_product_bom_id LEFT JOIN m_product p ON bom.m_product_id = p.m_product_id WHERE p.isactive = 'Y' AND b.isactive = 'Y' AND p2.isactive = 'Y'
;
-- Nov 28, 2021, 11:19:16 PM CET
CREATE OR REPLACE VIEW RV_Fact_Simple(AD_Client_ID, AD_Org_ID, IsActive, Created, CreatedBy, Updated, UpdatedBy, C_Project_ID, C_AcctSchema_ID, Account_ID, AccountValue, AccountType, DateAcct, FinYear_Mth, AmtAcct, FinYear, "case") AS SELECT rv_fact_acct.ad_client_id AS AD_Client_ID, rv_fact_acct.ad_org_id AS AD_Org_ID, rv_fact_acct.isactive AS IsActive, rv_fact_acct.created AS Created, rv_fact_acct.createdby AS CreatedBy, rv_fact_acct.updated AS Updated, rv_fact_acct.updatedby AS UpdatedBy, rv_fact_acct.c_project_id AS C_Project_ID, rv_fact_acct.c_acctschema_id AS C_AcctSchema_ID, rv_fact_acct.account_id AS Account_ID, rv_fact_acct.accountvalue AS AccountValue, rv_fact_acct.accounttype AS AccountType, rv_fact_acct.dateacct AS DateAcct, to_char(rv_fact_acct.dateacct, 'YYYY-MM') AS FinYear_Mth, sum(rv_fact_acct.amtacctdr - rv_fact_acct.amtacctcr) AS AmtAcct, to_char(rv_fact_acct.dateacct, '"FY"YYYY') AS FinYear, CASE rv_fact_acct.accounttype WHEN 'A' THEN 'B' WHEN 'E' THEN 'P' WHEN 'L' THEN 'B' WHEN 'M' THEN 'B' WHEN 'O' THEN 'B' WHEN 'R' THEN 'P' ELSE '9. Unknown' END AS "case" FROM rv_fact_acct WHERE rv_fact_acct.postingtype = 'A' GROUP BY rv_fact_acct.ad_client_id, rv_fact_acct.ad_org_id, rv_fact_acct.isactive, rv_fact_acct.created, rv_fact_acct.createdby, rv_fact_acct.updated, rv_fact_acct.updatedby, rv_fact_acct.c_project_id, rv_fact_acct.c_acctschema_id, rv_fact_acct.account_id, rv_fact_acct.accountvalue, rv_fact_acct.accounttype, rv_fact_acct.dateacct, rv_fact_acct.amtacct
;
-- Nov 28, 2021, 11:19:16 PM CET
CREATE OR REPLACE VIEW AD_ChangeLog_v(AD_Session_ID, AD_ChangeLog_ID, TableName, Record_ID, ColumnName, OldValue, NewValue, Name, Created) AS SELECT l.ad_session_id AS AD_Session_ID, l.ad_changelog_id AS AD_ChangeLog_ID, t.tablename AS TableName, l.record_id AS Record_ID, c.columnname AS ColumnName, l.oldvalue AS OldValue, l.newvalue AS NewValue, u.name AS Name, l.created AS Created FROM ad_changelog l JOIN ad_table t ON l.ad_table_id = t.ad_table_id JOIN ad_column c ON l.ad_column_id = c.ad_column_id JOIN ad_user u ON l.createdby = u.ad_user_id ORDER BY l.ad_session_id, l.ad_changelog_id, t.tablename, l.record_id, c.columnname
;
-- Nov 28, 2021, 11:19:17 PM CET
CREATE OR REPLACE VIEW AD_Field_v(AD_Window_ID, AD_Tab_ID, AD_Field_ID, AD_Table_ID, AD_Column_ID, Name, Description, Help, IsDisplayed, DisplayLogic, DisplayLength, SeqNo, SortNo, IsSameLine, IsHeading, IsFieldOnly, IsReadOnly, isencryptedfield, ObscureType, ColumnName, ColumnSQL, FieldLength, VFormat, DefaultValue, IsKey, IsParent, IsMandatory, IsIdentifier, IsTranslated, AD_Reference_Value_ID, Callout, AD_Reference_ID, AD_Val_Rule_ID, AD_Process_ID, IsAlwaysUpdateable, ReadOnlyLogic, MandatoryLogic, IsUpdateable, isencryptedcolumn, IsSelectionColumn, TableName, ValueMin, ValueMax, fieldgroup, validationcode, Included_Tab_ID, FieldGroupType, IsCollapsedByDefault, InfoFactoryClass, IsAutocomplete, IsAllowCopy, IsDisplayedGrid, SeqNoGrid, SeqNoSelection, XPosition, ColumnSpan, NumLines, IsToolbarButton, FormatPattern, IsAdvancedField, IsDefaultFocus, AD_Chart_ID, AD_LabelStyle_ID, AD_FieldStyle_ID, PA_DashboardContent_ID, Placeholder, IsHtml, IsQuickForm, AD_Val_Rule_Lookup_ID, validationcodelookup) AS SELECT t.ad_window_id AS AD_Window_ID, f.ad_tab_id AS AD_Tab_ID, f.ad_field_id AS AD_Field_ID, tbl.ad_table_id AS AD_Table_ID, f.ad_column_id AS AD_Column_ID, f.name AS Name, f.description AS Description, f.help AS Help, f.isdisplayed AS IsDisplayed, f.displaylogic AS DisplayLogic, f.displaylength AS DisplayLength, f.seqno AS SeqNo, f.sortno AS SortNo, f.issameline AS IsSameLine, f.isheading AS IsHeading, f.isfieldonly AS IsFieldOnly, f.isreadonly AS IsReadOnly, f.isencrypted AS isencryptedfield, f.obscuretype AS ObscureType, c.columnname AS ColumnName, COALESCE(f.columnsql, c.columnsql) AS ColumnSQL, c.fieldlength AS FieldLength, COALESCE(f.vformat, c.vformat) AS VFormat, COALESCE(f.defaultvalue, c.defaultvalue) AS DefaultValue, c.iskey AS IsKey, c.isparent AS IsParent, COALESCE(f.ismandatory, c.ismandatory) AS IsMandatory, c.isidentifier AS IsIdentifier, c.istranslated AS IsTranslated, COALESCE(f.ad_reference_value_id, c.ad_reference_value_id) AS AD_Reference_Value_ID, c.callout AS Callout, COALESCE(f.ad_reference_id, c.ad_reference_id) AS AD_Reference_ID, COALESCE(f.ad_val_rule_id, c.ad_val_rule_id) AS AD_Val_Rule_ID, c.ad_process_id AS AD_Process_ID, COALESCE(f.isalwaysupdateable, c.isalwaysupdateable) AS IsAlwaysUpdateable, COALESCE(f.readonlylogic, c.readonlylogic) AS ReadOnlyLogic, COALESCE(f.mandatorylogic, c.mandatorylogic) AS MandatoryLogic, COALESCE(f.isupdateable, c.isupdateable) AS IsUpdateable, c.isencrypted AS isencryptedcolumn, COALESCE(f.isselectioncolumn, c.isselectioncolumn) AS IsSelectionColumn, tbl.tablename AS TableName, c.valuemin AS ValueMin, c.valuemax AS ValueMax, fg.name AS fieldgroup, vr.code AS validationcode, f.included_tab_id AS Included_Tab_ID, fg.fieldgrouptype AS FieldGroupType, fg.iscollapsedbydefault AS IsCollapsedByDefault, COALESCE(f.infofactoryclass, c.infofactoryclass) AS InfoFactoryClass, c.isautocomplete AS IsAutocomplete, COALESCE(f.isallowcopy, c.isallowcopy) AS IsAllowCopy, f.isdisplayedgrid AS IsDisplayedGrid, f.seqnogrid AS SeqNoGrid, c.seqnoselection AS SeqNoSelection, f.xposition AS XPosition, f.columnspan AS ColumnSpan, f.numlines AS NumLines, COALESCE(f.istoolbarbutton, c.istoolbarbutton) AS IsToolbarButton, c.formatpattern AS FormatPattern, f.isadvancedfield AS IsAdvancedField, f.isdefaultfocus AS IsDefaultFocus, c.ad_chart_id AS AD_Chart_ID, f.ad_labelstyle_id AS AD_LabelStyle_ID, f.ad_fieldstyle_id AS AD_FieldStyle_ID, c.pa_dashboardcontent_id AS PA_DashboardContent_ID, COALESCE(f.placeholder, c.placeholder) AS Placeholder, c.ishtml AS IsHtml, f.isquickform AS IsQuickForm, COALESCE(f.ad_val_rule_lookup_id, c.ad_val_rule_lookup_id) AS AD_Val_Rule_Lookup_ID, vrf.code AS validationcodelookup FROM ad_field f JOIN ad_tab t ON f.ad_tab_id = t.ad_tab_id LEFT JOIN ad_fieldgroup fg ON f.ad_fieldgroup_id = fg.ad_fieldgroup_id LEFT JOIN ad_column c ON f.ad_column_id = c.ad_column_id JOIN ad_table tbl ON c.ad_table_id = tbl.ad_table_id LEFT JOIN ad_val_rule vr ON vr.ad_val_rule_id = COALESCE(f.ad_val_rule_id, c.ad_val_rule_id) LEFT JOIN ad_val_rule vrf ON vrf.ad_val_rule_id = COAL
;
-- Nov 28, 2021, 11:19:17 PM CET
CREATE OR REPLACE VIEW AD_Field_vt(AD_Language, AD_Window_ID, AD_Tab_ID, AD_Field_ID, AD_Table_ID, AD_Column_ID, Name, Description, Help, IsDisplayed, DisplayLogic, DisplayLength, SeqNo, SortNo, IsSameLine, IsHeading, IsFieldOnly, IsReadOnly, isencryptedfield, ObscureType, ColumnName, ColumnSQL, FieldLength, VFormat, DefaultValue, IsKey, IsParent, IsMandatory, IsIdentifier, IsTranslated, AD_Reference_Value_ID, Callout, AD_Reference_ID, AD_Val_Rule_ID, AD_Process_ID, IsAlwaysUpdateable, ReadOnlyLogic, MandatoryLogic, IsUpdateable, isencryptedcolumn, IsSelectionColumn, TableName, ValueMin, ValueMax, fieldgroup, validationcode, Included_Tab_ID, FieldGroupType, IsCollapsedByDefault, InfoFactoryClass, IsAutocomplete, IsAllowCopy, IsDisplayedGrid, SeqNoGrid, SeqNoSelection, XPosition, ColumnSpan, NumLines, IsToolbarButton, FormatPattern, IsAdvancedField, IsDefaultFocus, AD_Chart_ID, AD_LabelStyle_ID, AD_FieldStyle_ID, PA_DashboardContent_ID, Placeholder, IsHtml, IsQuickForm, AD_Val_Rule_Lookup_ID, validationcodelookup) AS SELECT trl.ad_language AS AD_Language, t.ad_window_id AS AD_Window_ID, f.ad_tab_id AS AD_Tab_ID, f.ad_field_id AS AD_Field_ID, tbl.ad_table_id AS AD_Table_ID, f.ad_column_id AS AD_Column_ID, trl.name AS Name, trl.description AS Description, trl.help AS Help, f.isdisplayed AS IsDisplayed, f.displaylogic AS DisplayLogic, f.displaylength AS DisplayLength, f.seqno AS SeqNo, f.sortno AS SortNo, f.issameline AS IsSameLine, f.isheading AS IsHeading, f.isfieldonly AS IsFieldOnly, f.isreadonly AS IsReadOnly, f.isencrypted AS isencryptedfield, f.obscuretype AS ObscureType, c.columnname AS ColumnName, COALESCE(f.columnsql, c.columnsql) AS ColumnSQL, c.fieldlength AS FieldLength, COALESCE(f.vformat, c.vformat) AS VFormat, COALESCE(f.defaultvalue, c.defaultvalue) AS DefaultValue, c.iskey AS IsKey, c.isparent AS IsParent, COALESCE(f.ismandatory, c.ismandatory) AS IsMandatory, c.isidentifier AS IsIdentifier, c.istranslated AS IsTranslated, COALESCE(f.ad_reference_value_id, c.ad_reference_value_id) AS AD_Reference_Value_ID, c.callout AS Callout, COALESCE(f.ad_reference_id, c.ad_reference_id) AS AD_Reference_ID, COALESCE(f.ad_val_rule_id, c.ad_val_rule_id) AS AD_Val_Rule_ID, c.ad_process_id AS AD_Process_ID, COALESCE(f.isalwaysupdateable, c.isalwaysupdateable) AS IsAlwaysUpdateable, COALESCE(f.readonlylogic, c.readonlylogic) AS ReadOnlyLogic, COALESCE(f.mandatorylogic, c.mandatorylogic) AS MandatoryLogic, COALESCE(f.isupdateable, c.isupdateable) AS IsUpdateable, c.isencrypted AS isencryptedcolumn, COALESCE(f.isselectioncolumn, c.isselectioncolumn) AS IsSelectionColumn, tbl.tablename AS TableName, c.valuemin AS ValueMin, c.valuemax AS ValueMax, fgt.name AS fieldgroup, vr.code AS validationcode, f.included_tab_id AS Included_Tab_ID, fg.fieldgrouptype AS FieldGroupType, fg.iscollapsedbydefault AS IsCollapsedByDefault, COALESCE(f.infofactoryclass, c.infofactoryclass) AS InfoFactoryClass, c.isautocomplete AS IsAutocomplete, COALESCE(f.isallowcopy, c.isallowcopy) AS IsAllowCopy, f.isdisplayedgrid AS IsDisplayedGrid, f.seqnogrid AS SeqNoGrid, c.seqnoselection AS SeqNoSelection, f.xposition AS XPosition, f.columnspan AS ColumnSpan, f.numlines AS NumLines, COALESCE(f.istoolbarbutton, c.istoolbarbutton) AS IsToolbarButton, c.formatpattern AS FormatPattern, f.isadvancedfield AS IsAdvancedField, f.isdefaultfocus AS IsDefaultFocus, c.ad_chart_id AS AD_Chart_ID, f.ad_labelstyle_id AS AD_LabelStyle_ID, f.ad_fieldstyle_id AS AD_FieldStyle_ID, c.pa_dashboardcontent_id AS PA_DashboardContent_ID, COALESCE(trl.placeholder, ct.placeholder) AS Placeholder, c.ishtml AS IsHtml, f.isquickform AS IsQuickForm, COALESCE(f.ad_val_rule_lookup_id, c.ad_val_rule_lookup_id) AS AD_Val_Rule_Lookup_ID, vrf.code AS validationcodelookup FROM ad_field f JOIN ad_field_trl trl ON f.ad_field_id = trl.ad_field_id JOIN ad_tab t ON f.ad_tab_id = t.ad_tab_id LEFT JOIN ad_fieldgroup fg ON f.ad_fieldgroup_id = fg.ad_fieldgroup_id LEFT JOIN ad_fieldgroup_trl fgt ON f.ad_fieldgroup_id = fgt.ad_fieldgroup_id AND trl.ad_language = fgt.ad_language LEFT JOIN ad_column c ON f.ad
;
-- Nov 28, 2021, 11:19:17 PM CET
CREATE OR REPLACE VIEW AD_Org_v(AD_Client_ID, AD_Org_ID, IsActive, Created, CreatedBy, Updated, UpdatedBy, Value, Name, Description, IsSummary, C_Location_ID, DUNS, TaxID, Supervisor_ID, Parent_Org_ID, AD_OrgType_ID, M_Warehouse_ID, C_BPartner_ID) AS SELECT o.ad_client_id AS AD_Client_ID, o.ad_org_id AS AD_Org_ID, o.isactive AS IsActive, o.created AS Created, o.createdby AS CreatedBy, o.updated AS Updated, o.updatedby AS UpdatedBy, o.value AS Value, o.name AS Name, o.description AS Description, o.issummary AS IsSummary, i.c_location_id AS C_Location_ID, i.duns AS DUNS, i.taxid AS TaxID, i.supervisor_id AS Supervisor_ID, i.parent_org_id AS Parent_Org_ID, i.ad_orgtype_id AS AD_OrgType_ID, i.m_warehouse_id AS M_Warehouse_ID, bp.c_bpartner_id AS C_BPartner_ID FROM ad_org o JOIN ad_orginfo i ON o.ad_org_id = i.ad_org_id LEFT JOIN c_bpartner bp ON o.ad_org_id = bp.ad_orgbp_id
;
-- Nov 28, 2021, 11:19:17 PM CET
CREATE OR REPLACE VIEW AD_Tab_v(AD_Tab_ID, AD_Window_ID, AD_Table_ID, Name, Description, Help, SeqNo, IsSingleRow, HasTree, IsInfoTab, ReplicationType, TableName, AccessLevel, IsSecurityEnabled, IsDeleteable, IsHighVolume, IsView, hasassociation, IsTranslationTab, IsReadOnly, AD_Image_ID, TabLevel, WhereClause, OrderByClause, CommitWarning, ReadOnlyLogic, DisplayLogic, AD_Column_ID, AD_Process_ID, IsSortTab, IsInsertRecord, IsAdvancedTab, AD_ColumnSortOrder_ID, AD_ColumnSortYesNo_ID, Included_Tab_ID, Parent_Column_ID, AD_Tab_UU, AD_Table_UU, TreeDisplayedOn, MaxQueryRecords, IsAllowAdvancedLookup, IsLookupOnlySelection, AD_TabType) AS SELECT t.ad_tab_id AS AD_Tab_ID, t.ad_window_id AS AD_Window_ID, t.ad_table_id AS AD_Table_ID, t.name AS Name, t.description AS Description, t.help AS Help, t.seqno AS SeqNo, t.issinglerow AS IsSingleRow, t.hastree AS HasTree, t.isinfotab AS IsInfoTab, tbl.replicationtype AS ReplicationType, tbl.tablename AS TableName, tbl.accesslevel AS AccessLevel, tbl.issecurityenabled AS IsSecurityEnabled, tbl.isdeleteable AS IsDeleteable, tbl.ishighvolume AS IsHighVolume, tbl.isview AS IsView, CAST('N' AS char(1)) AS hasassociation, t.istranslationtab AS IsTranslationTab, t.isreadonly AS IsReadOnly, t.ad_image_id AS AD_Image_ID, t.tablevel AS TabLevel, t.whereclause AS WhereClause, t.orderbyclause AS OrderByClause, t.commitwarning AS CommitWarning, t.readonlylogic AS ReadOnlyLogic, t.displaylogic AS DisplayLogic, t.ad_column_id AS AD_Column_ID, t.ad_process_id AS AD_Process_ID, t.issorttab AS IsSortTab, t.isinsertrecord AS IsInsertRecord, t.isadvancedtab AS IsAdvancedTab, t.ad_columnsortorder_id AS AD_ColumnSortOrder_ID, t.ad_columnsortyesno_id AS AD_ColumnSortYesNo_ID, t.included_tab_id AS Included_Tab_ID, t.parent_column_id AS Parent_Column_ID, t.ad_tab_uu AS AD_Tab_UU, tbl.ad_table_uu AS AD_Table_UU, t.treedisplayedon AS TreeDisplayedOn, t.maxqueryrecords AS MaxQueryRecords, t.isallowadvancedlookup AS IsAllowAdvancedLookup, t.islookuponlyselection AS IsLookupOnlySelection, t.ad_tabtype AS AD_TabType FROM ad_tab t JOIN ad_table tbl ON t.ad_table_id = tbl.ad_table_id WHERE t.isactive = 'Y' AND tbl.isactive = 'Y'
;
-- Nov 28, 2021, 11:19:17 PM CET
CREATE OR REPLACE VIEW AD_Tab_vt(AD_Language, AD_Tab_ID, AD_Window_ID, AD_Table_ID, Name, Description, Help, SeqNo, IsSingleRow, HasTree, IsInfoTab, ReplicationType, TableName, AccessLevel, IsSecurityEnabled, IsDeleteable, IsHighVolume, IsView, hasassociation, IsTranslationTab, IsReadOnly, AD_Image_ID, TabLevel, WhereClause, OrderByClause, CommitWarning, ReadOnlyLogic, DisplayLogic, AD_Column_ID, AD_Process_ID, IsSortTab, IsInsertRecord, IsAdvancedTab, AD_ColumnSortOrder_ID, AD_ColumnSortYesNo_ID, Included_Tab_ID, Parent_Column_ID, AD_Tab_UU, AD_Table_UU, TreeDisplayedOn, MaxQueryRecords, IsAllowAdvancedLookup, IsLookupOnlySelection, AD_TabType) AS SELECT trl.ad_language AS AD_Language, t.ad_tab_id AS AD_Tab_ID, t.ad_window_id AS AD_Window_ID, t.ad_table_id AS AD_Table_ID, trl.name AS Name, trl.description AS Description, trl.help AS Help, t.seqno AS SeqNo, t.issinglerow AS IsSingleRow, t.hastree AS HasTree, t.isinfotab AS IsInfoTab, tbl.replicationtype AS ReplicationType, tbl.tablename AS TableName, tbl.accesslevel AS AccessLevel, tbl.issecurityenabled AS IsSecurityEnabled, tbl.isdeleteable AS IsDeleteable, tbl.ishighvolume AS IsHighVolume, tbl.isview AS IsView, CAST('N' AS char(1)) AS hasassociation, t.istranslationtab AS IsTranslationTab, t.isreadonly AS IsReadOnly, t.ad_image_id AS AD_Image_ID, t.tablevel AS TabLevel, t.whereclause AS WhereClause, t.orderbyclause AS OrderByClause, trl.commitwarning AS CommitWarning, t.readonlylogic AS ReadOnlyLogic, t.displaylogic AS DisplayLogic, t.ad_column_id AS AD_Column_ID, t.ad_process_id AS AD_Process_ID, t.issorttab AS IsSortTab, t.isinsertrecord AS IsInsertRecord, t.isadvancedtab AS IsAdvancedTab, t.ad_columnsortorder_id AS AD_ColumnSortOrder_ID, t.ad_columnsortyesno_id AS AD_ColumnSortYesNo_ID, t.included_tab_id AS Included_Tab_ID, t.parent_column_id AS Parent_Column_ID, t.ad_tab_uu AS AD_Tab_UU, tbl.ad_table_uu AS AD_Table_UU, t.treedisplayedon AS TreeDisplayedOn, t.maxqueryrecords AS MaxQueryRecords, t.isallowadvancedlookup AS IsAllowAdvancedLookup, t.islookuponlyselection AS IsLookupOnlySelection, t.ad_tabtype AS AD_TabType FROM ad_tab t JOIN ad_table tbl ON t.ad_table_id = tbl.ad_table_id JOIN ad_tab_trl trl ON t.ad_tab_id = trl.ad_tab_id WHERE t.isactive = 'Y' AND tbl.isactive = 'Y'
;
-- Nov 28, 2021, 11:19:17 PM CET
CREATE OR REPLACE VIEW AD_User_Roles_v(Name, roleName) AS SELECT u.name AS Name, r.name AS roleName FROM ad_user_roles ur JOIN ad_user u ON ur.ad_user_id = u.ad_user_id JOIN ad_role r ON ur.ad_role_id = r.ad_role_id
;
-- Nov 28, 2021, 11:19:17 PM CET
CREATE OR REPLACE VIEW AD_Window_vt(AD_Language, AD_Window_ID, Name, Description, Help, WindowType, AD_Color_ID, AD_Image_ID, IsActive, WinWidth, WinHeight, IsSOTrx, AD_Window_UU) AS SELECT trl.ad_language AS AD_Language, bt.ad_window_id AS AD_Window_ID, trl.name AS Name, trl.description AS Description, trl.help AS Help, bt.windowtype AS WindowType, bt.ad_color_id AS AD_Color_ID, bt.ad_image_id AS AD_Image_ID, bt.isactive AS IsActive, bt.winwidth AS WinWidth, bt.winheight AS WinHeight, bt.issotrx AS IsSOTrx, bt.ad_window_uu AS AD_Window_UU FROM ad_window bt JOIN ad_window_trl trl ON bt.ad_window_id = trl.ad_window_id WHERE bt.isactive = 'Y'
;
-- Nov 28, 2021, 11:19:17 PM CET
CREATE OR REPLACE VIEW C_Dunning_Header_vt(AD_Client_ID, AD_Org_ID, IsActive, Created, CreatedBy, Updated, UpdatedBy, AD_Language, C_DunningRun_ID, C_DunningRunEntry_ID, DunningDate, PrintName, DocumentNote, C_BPartner_ID, BPValue, BPTaxID, NAICS, DUNS, Org_Location_ID, TaxID, SalesRep_ID, SalesRep_Name, BPGreeting, Name, Name2, BPContactGreeting, Title, Phone, ContactName, C_Location_ID, ReferenceNo, Postal, Amt, Qty, Note, Logo_ID, C_Dunning_ID, C_DunningRun_C_DunningLevel_ID, c_dunningrun_description, Processed, Processing, SendIt, C_DunningRunEntry_AD_Org_ID, AD_User_ID, C_BPartner_Location_ID, C_Currency_ID, C_DunRunEntry_C_DunLevel_ID, c_dunningrunentry_created, C_DunningRunEntry_CreatedBy, c_dunningrunentry_isactive, c_dunningrunentry_processed, c_dunningrunentry_updated, C_DunningRunEntry_UpdatedBy, C_DunningLevel_AD_Org_ID, C_DunningLevel_C_Dunning_ID, ChargeFee, ChargeInterest, C_PaymentTerm_ID, DaysAfterDue, DaysBetweenDunning, c_dunninglevel_description, Dunning_PrintFormat_ID, FeeAmt, InterestPercent, InvoiceCollectionType, c_dunninglevel_isactive, IsSetCreditStop, IsSetPaymentTerm, IsShowAllDue, IsShowNotDue, IsStatement, c_dunninglevel_name, c_bpartner_acqusitioncost, c_bpartner_actuallifetimevalue, c_bpartner_ad_language, C_BPartner_AD_OrgBP_ID, C_BPartner_AD_Org_ID, C_BPartner_BPartner_Parent_ID, C_BPartner_C_BP_Group_ID, C_BPartner_C_Greeting_ID, C_BPartner_InvoiceSchedule_ID, C_BPartner_C_PaymentTerm_ID, c_bpartner_created, C_BPartner_CreatedBy, C_BPartner_C_TaxGroup_ID, c_bpartner_deliveryrule, c_bpartner_deliveryviarule, c_bpartner_description, c_bpartner_dunninggrace, c_bpartner_firstsale, c_bpartner_flatdiscount, c_bpartner_freightcostrule, c_bpartner_invoicerule, c_bpartner_isactive, c_bpartner_iscustomer, c_bpartner_isdiscountprinted, c_bpartner_isemployee, c_bpartner_ismanufacturer, c_bpartner_isonetime, c_bpartner_ispotaxexempt, c_bpartner_isprospect, c_bpartner_issalesrep, c_bpartner_issummary, c_bpartner_istaxexempt, c_bpartner_isvendor, C_BPartner_Logo_ID, C_BPartner_M_DiscountSchema_ID, C_BPartner_M_PriceList_ID, c_bpartner_naics, c_bpartner_numberemployees, c_bpartner_paymentrule, c_bpartner_paymentrulepo, C_BPartnerPO_DiscountSchema_ID, C_BPartner_PO_PaymentTerm_ID, C_BPartner_PO_PriceList_ID, c_bpartner_poreference, c_bpartner_potentiallifetimev, c_bpartner_rating, C_BPartner_SalesRep_ID, c_bpartner_salesvolume, c_bpartner_sendemail, c_bpartner_shareofcustomer, c_bpartner_shelflifeminpct, c_bpartner_so_creditlimit, c_bpartner_socreditstatus, c_bpartner_so_creditused, c_bpartner_so_description, c_bpartner_totalopenbalance, c_bpartner_updated, C_BPartner_UpdatedBy, c_bpartner_url, C_BPartner_Greeting_AD_Org_ID, c_bpartner_greeting_isactive, c_bpartner_greeting_isfirstna, c_bpartner_greeting_name, C_BPartner_Location_AD_Org_ID, c_bpartner_location_created, C_BPartner_Location_CreatedBy, C_SalesRegion_ID, c_bpartner_location_fax, c_bpartner_location_isactive, IsBillTo, ISDN, IsPayFrom, IsRemitTo, IsShipTo, c_bpartner_location_name, c_bpartner_location_phone, c_bpartner_location_phone2, c_bpartner_location_updated, C_BPartner_Location_UpdatedBy, Address1, Address2, Address3, Address4, C_Location_AD_Org_ID, C_City_ID, C_Country_ID, City, c_location_created, C_Location_CreatedBy, C_Region_ID, c_location_isactive, Postal_Add, RegionName, c_location_updated, C_Location_UpdatedBy, AD_User_AD_Org_ID, AD_User_AD_AD_OrgTrx_ID, ad_user_ad_birthday, AD_User_C_BPartner_ID, AD_User_C_BPartner_Location_ID, AD_User_C_Greeting_ID, ad_user_comments, ad_user_created, AD_User_CreatedBy, ad_user_description, ad_user_email, ad_user_fax, ad_user_isactive, ad_user_lastcontact, ad_user_lastresult, ad_user_name, ad_user_phone2, AD_User_Supervisor_ID, ad_user_updated, AD_User_UpdatedBy, ad_user_value, C_User_Greeting_AD_Org_ID, c_user_greeting_isactive, c_user_greeting_isfirstnameon, c_user_greeting_name, AD_OrgInfo_AD_Org_ID, AD_OrgType_ID, C_Calendar_ID, ad_orginfo_created, AD_OrgInfo_CreatedBy, DropShip_Warehouse_ID, ad_orginfo_duns, ad_orginfo_email, ad_orginfo_fax, ad_orginfo_isactive, M_Warehouse_ID, Parent_Or
;
-- Nov 28, 2021, 11:19:17 PM CET
CREATE OR REPLACE VIEW C_Dunning_Line_vt(AD_Client_ID, AD_Org_ID, IsActive, Created, CreatedBy, Updated, UpdatedBy, AD_Language, C_DunningRunLine_ID, C_DunningRunEntry_ID, Amt, ConvertedAmt, DaysDue, TimesDunned, InterestAmt, FeeAmt, TotalAmt, C_Invoice_ID, IsSOTrx, DocumentNo, DocStatus, DateTrx, C_DocType_ID, DocumentType, Description, C_Currency_ID, C_Campaign_ID, C_Project_ID, C_Activity_ID, User1_ID, User2_ID, DateAcct, C_ConversionType_ID, AD_OrgTrx_ID, POReference, DateOrdered, DateInvoiced, IsInDispute, PaymentTerm, C_Charge_ID, ChargeAmt, TotalLines, GrandTotal, AmtInWords, M_PriceList_ID, IsPaid, IsAllocated, TenderType, DiscountAmt, C_InvoicePaySchedule_ID, C_Payment_ID, c_dunningrunline_isindispute, OpenAmt, c_dunningrunline_processed, C_Invoice_AD_Org_ID, AD_User_ID, C_Invoice_C_BPartner_ID, C_BPartner_Location_ID, C_DocTypeTarget_ID, C_DunningLevel_ID, C_Invoice_C_Order_ID, C_Invoice_C_Payment_ID, c_invoice_created, C_Invoice_CreatedBy, DatePrinted, DocAction, DunningGrace, GenerateTo, InvoiceCollectionType, c_invoice_isactive, c_invoice_isapproved, IsDiscountPrinted, IsPayScheduleValid, IsPrinted, c_invoice_isselfservice, IsTaxIncluded, IsTransferred, M_RMA_ID, PaymentRule, c_invoice_posted, c_invoice_processedon, Processing, Ref_Invoice_ID, C_Invoice_Reversal_ID, SalesRep_ID, SendEMail, c_invoice_updated, C_Invoice_UpdatedBy, C_PaymentTerm_AD_Org_ID, AfterDelivery, C_PaymentTerm_ID, c_paymentterm_description, Discount, Discount2, DiscountDays, DiscountDays2, DocumentNote, FixMonthCutoff, FixMonthDay, FixMonthOffset, GraceDays, c_paymentterm_isactive, IsDueFixed, IsNextBusinessDay, IsValid, NetDay, NetDays, PaymentTermUsage, c_paymentterm_value, A_City, A_Country, C_Payment_AD_Org_ID, A_EMail, A_Ident_DL, A_Name, A_State, A_Street, A_Zip, C_Payment_C_BPartner_ID, C_Payment_C_Charge_ID, c_payment_chargeamt, CheckNo, C_Payment_C_Invoice_ID, C_Payment_C_Order_ID, C_PaymentBatch_ID, c_payment_created, C_Payment_CreatedBy, c_payment_isactive, IsApproved, IsDelayedCapture, IsOnline, IsOverUnderPayment, IsPrepayment, IsReconciled, c_payment_isselfservice, Micr, Orig_TrxID, OverUnderAmt, PayAmt, PONum, c_payment_posted, c_payment_processed, c_payment_processedon, R_AuthCode, R_AuthCode_DC, R_AvsAddr, R_AvsZip, R_CVV2Match, Ref_Payment_ID, C_Payment_Reversal_ID, R_Info, RoutingNo, R_PnRef, R_PnRef_DC, R_RespMsg, R_Result, Swipe, TaxAmt, TrxType, c_payment_updated, C_Payment_UpdatedBy, VoiceAuthCode, WriteOffAmt) AS SELECT drl.ad_client_id AS AD_Client_ID, drl.ad_org_id AS AD_Org_ID, drl.isactive AS IsActive, drl.created AS Created, drl.createdby AS CreatedBy, drl.updated AS Updated, drl.updatedby AS UpdatedBy, COALESCE(dt.ad_language, dtp.ad_language) AS AD_Language, drl.c_dunningrunline_id AS C_DunningRunLine_ID, drl.c_dunningrunentry_id AS C_DunningRunEntry_ID, drl.amt AS Amt, drl.convertedamt AS ConvertedAmt, drl.daysdue AS DaysDue, drl.timesdunned AS TimesDunned, drl.interestamt AS InterestAmt, drl.feeamt AS FeeAmt, drl.totalamt AS TotalAmt, drl.c_invoice_id AS C_Invoice_ID, COALESCE(i.issotrx, p.isreceipt) AS IsSOTrx, COALESCE(i.documentno, p.documentno) AS DocumentNo, COALESCE(i.docstatus, p.docstatus) AS DocStatus, COALESCE(i.dateinvoiced, p.datetrx) AS DateTrx, COALESCE(i.c_doctype_id, p.c_doctype_id) AS C_DocType_ID, COALESCE(dt.printname, dtp.printname) AS DocumentType, COALESCE(i.description, p.description) AS Description, COALESCE(i.c_currency_id, p.c_currency_id) AS C_Currency_ID, COALESCE(i.c_campaign_id, p.c_campaign_id) AS C_Campaign_ID, COALESCE(i.c_project_id, p.c_project_id) AS C_Project_ID, COALESCE(i.c_activity_id, p.c_activity_id) AS C_Activity_ID, COALESCE(i.user1_id, p.user1_id) AS User1_ID, COALESCE(i.user2_id, p.user2_id) AS User2_ID, COALESCE(i.dateacct, p.dateacct) AS DateAcct, COALESCE(i.c_conversiontype_id, p.c_conversiontype_id) AS C_ConversionType_ID, COALESCE(i.ad_orgtrx_id, p.ad_orgtrx_id) AS AD_OrgTrx_ID, i.poreference AS POReference, i.dateordered AS DateOrdered, i.dateinvoiced AS DateInvoiced, i.isindispute AS IsInDispute, ptt.name AS PaymentTerm, i.c_charge_id AS C_Charge_ID,
;
-- Nov 28, 2021, 11:19:17 PM CET
CREATE OR REPLACE VIEW C_Invoice_Candidate_v(AD_Client_ID, AD_Org_ID, C_BPartner_ID, C_Order_ID, DocumentNo, DateOrdered, C_DocType_ID, TotalLines) AS SELECT o.ad_client_id AS AD_Client_ID, o.ad_org_id AS AD_Org_ID, o.c_bpartner_id AS C_BPartner_ID, o.c_order_id AS C_Order_ID, o.documentno AS DocumentNo, o.dateordered AS DateOrdered, o.c_doctype_id AS C_DocType_ID, sum((l.qtyordered - l.qtyinvoiced) * l.priceactual) AS TotalLines FROM c_order o JOIN c_orderline l ON o.c_order_id = l.c_order_id JOIN c_bpartner bp ON o.c_bpartner_id = bp.c_bpartner_id LEFT JOIN c_invoiceschedule si ON bp.c_invoiceschedule_id = si.c_invoiceschedule_id WHERE (o.docstatus IN ('CO', 'CL', 'IP')) AND (o.c_doctype_id IN ( SELECT c_doctype.c_doctype_id FROM c_doctype WHERE c_doctype.docbasetype = 'SOO' AND (c_doctype.docsubtypeso NOT IN ('ON', 'OB', 'WR')))) AND l.qtyordered <> l.qtyinvoiced AND (o.invoicerule = 'I' OR o.invoicerule = 'O' AND NOT (EXISTS ( SELECT 1 FROM c_orderline zz1 WHERE zz1.c_order_id = o.c_order_id AND zz1.qtyordered <> zz1.qtydelivered)) OR o.invoicerule = 'D' AND l.qtyinvoiced <> l.qtydelivered OR o.invoicerule = 'S' AND bp.c_invoiceschedule_id IS NULL OR o.invoicerule = 'S' AND bp.c_invoiceschedule_id IS NOT NULL AND (si.invoicefrequency IS NULL OR si.invoicefrequency = 'D' OR si.invoicefrequency = 'W' OR si.invoicefrequency = 'T' AND (trunc(o.dateordered) <= (firstof(statement_timestamp(), 'MM') + si.invoicedaycutoff - 1) AND trunc(statement_timestamp()) >= (firstof(o.dateordered, 'MM') + si.invoiceday - 1) OR trunc(o.dateordered) <= (firstof(statement_timestamp(), 'MM') + si.invoicedaycutoff + 14) AND trunc(statement_timestamp()) >= (firstof(o.dateordered, 'MM') + si.invoiceday + 14)) OR si.invoicefrequency = 'M' AND trunc(o.dateordered) <= (firstof(statement_timestamp(), 'MM') + si.invoicedaycutoff - 1) AND trunc(statement_timestamp()) >= (firstof(o.dateordered, 'MM') + si.invoiceday - 1))) GROUP BY o.ad_client_id, o.ad_org_id, o.c_bpartner_id, o.c_order_id, o.documentno, o.dateordered, o.c_doctype_id
;
-- Nov 28, 2021, 11:19:17 PM CET
CREATE OR REPLACE VIEW C_Invoice_Header_vt(AD_Client_ID, AD_Org_ID, IsActive, Created, CreatedBy, Updated, UpdatedBy, AD_Language, C_Invoice_ID, IsSOTrx, DocumentNo, DocStatus, C_DocType_ID, C_BPartner_ID, BPValue, BPTaxID, NAICS, DUNS, Org_Location_ID, TaxID, DocumentType, DocumentTypeNote, C_Order_ID, SalesRep_ID, SalesRep_Name, DateInvoiced, BPGreeting, Name, Name2, BPContactGreeting, Title, Phone, ContactName, C_Location_ID, ReferenceNo, Postal, Description, POReference, DateOrdered, C_Currency_ID, PaymentTerm, PaymentTermNote, C_Charge_ID, ChargeAmt, TotalLines, GrandTotal, AmtInWords, M_PriceList_ID, IsTaxIncluded, C_Campaign_ID, C_Project_ID, C_Activity_ID, IsPaid, Logo_ID, C_Invoice_AD_OrgTrx_ID, AD_User_ID, C_BPartner_Location_ID, C_ConversionType_ID, C_DocTypeTarget_ID, C_DunningLevel_ID, C_Payment_ID, DateAcct, DatePrinted, DocAction, DunningGrace, GenerateTo, InvoiceCollectionType, IsApproved, IsDiscountPrinted, IsInDispute, IsPayScheduleValid, IsPrinted, c_invoice_isselfservice, IsTransferred, M_RMA_ID, PaymentRule, Posted, ProcessedOn, Processing, Ref_Invoice_ID, Reversal_ID, SendEMail, User1_ID, User2_ID, C_PaymentTerm_AD_Org_ID, AfterDelivery, C_PaymentTerm_ID, c_paymentterm_description, Discount, Discount2, DiscountDays, DiscountDays2, FixMonthCutoff, FixMonthDay, FixMonthOffset, GraceDays, c_paymentterm_isactive, IsDefault, IsDueFixed, IsNextBusinessDay, IsValid, NetDay, NetDays, PaymentTermUsage, c_paymentterm_value, bp_acqusitioncost, bp_actuallifetimevalue, bp_ad_language, BP_AD_OrgBP_ID, BP_AD_Org_ID, BP_BPartner_Parent_ID, BP_C_BP_Group_ID, BP_C_Dunning_ID, BP_C_Greeting_ID, BP_C_InvoiceSchedule_ID, BP_C_PaymentTerm_ID, bp_created, BP_CreatedBy, BP_C_TaxGroup_ID, bp_deliveryrule, bp_deliveryviarule, bp_description, bp_dunninggrace, bp_firstsale, bp_flatdiscount, bp_freightcostrule, bp_invoicerule, bp_isactive, bp_iscustomer, bp_isdiscountprinted, bp_isemployee, bp_ismanufacturer, bp_isonetime, bp_ispotaxexempt, bp_isprospect, bp_issalesrep, bp_issummary, bp_istaxexempt, bp_isvendor, BP_Logo_ID, BP_M_DiscountSchema_ID, BP_M_PriceList_ID, bp_naics, bp_numberemployees, bp_paymentrule, bp_paymentrulepo, BP_PO_DiscountSchema_ID, BP_PO_PaymentTerm_ID, BP_PO_PriceList_ID, bp_poreference, bp_potentiallifetimevalue, bp_rating, BP_SalesRep_ID, bp_salesvolume, bp_sendemail, bp_shareofcustomer, bp_shelflifeminpct, bp_so_creditlimit, bp_socreditstatus, bp_so_creditused, bp_so_description, bp_totalopenbalance, bp_updated, BP_UpdatedBy, bp_url, c_greeting_isactive, IsFirstNameOnly, c_greeting_name, BP_Location_AD_Org_ID, BP_Location_C_BPartner_ID, bp_location_created, BP_Location_CreatedBy, C_SalesRegion_ID, bp_location_fax, bp_location_isactive, IsBillTo, ISDN, IsPayFrom, IsRemitTo, IsShipTo, bp_location_name, bp_location_phone, bp_location_phone2, bp_location_updated, BP_Location_UpdatedBy, Address1, Address2, Address3, Address4, C_Location_AD_Org_ID, C_City_ID, C_Country_ID, City, c_location_created, C_Location_CreatedBy, C_Region_ID, c_location_isactive, RegionName, c_location_updated, C_Location_UpdatedBy, AD_User_AD_Org_ID, AD_User_AD_AD_OrgTrx_ID, ad_user_ad_birthday, AD_User_C_BPartner_ID, AD_User_C_BPartner_Location_ID, AD_User_C_Greeting_ID, ad_user_comments, ad_user_created, AD_User_CreatedBy, ad_user_description, ad_user_email, ad_user_fax, ad_user_isactive, ad_user_lastcontact, ad_user_lastresult, ad_user_phone2, AD_User_Supervisor_ID, ad_user_updated, AD_User_UpdatedBy, ad_user_value, user_greeting_isactive, user_greeting_isfirstnameonly, user_greeting_name, AD_OrgInfo_AD_Org_ID, AD_OrgType_ID, C_Calendar_ID, ad_orginfo_created, AD_OrgInfo_CreatedBy, DropShip_Warehouse_ID, ad_orginfo_duns, ad_orginfo_email, ad_orginfo_fax, ad_orginfo_isactive, M_Warehouse_ID, Parent_Org_ID, ad_orginfo_phone, ad_orginfo_phone2, ReceiptFooterMsg, Supervisor_ID, ad_orginfo_updated, AD_OrgInfo_UpdatedBy, SalesRep_AD_Org_ID, SalesRep_AD_AD_OrgTrx_ID, salesrep_ad_birthday, SalesRep_C_BPartner_ID, SalesRep_C_BP_Location_ID, SalesRep_C_Greeting_ID, salesrep_comments, salesrep_created, SalesRep_CreatedBy, salesrep_descripti
;
-- Nov 28, 2021, 11:19:17 PM CET
CREATE OR REPLACE VIEW C_Invoice_LineTax_vt(AD_Client_ID, AD_Org_ID, IsActive, Created, CreatedBy, Updated, UpdatedBy, AD_Language, C_Invoice_ID, C_InvoiceLine_ID, C_Tax_ID, TaxAmt, LineTotalAmt, TaxIndicator, Line, M_Product_ID, QtyInvoiced, QtyEntered, UOMSymbol, Name, Description, DocumentNote, UPC, SKU, ProductValue, ResourceDescription, PriceList, PriceEnteredList, Discount, PriceActual, PriceEntered, LineNetAmt, M_AttributeSetInstance_ID, M_AttributeSet_ID, SerNo, Lot, M_Lot_ID, GuaranteeDate, ProductDescription, ImageURL, C_Campaign_ID, C_Project_ID, C_Activity_ID, C_ProjectPhase_ID, C_ProjectTask_ID, C_InvoiceLine_AD_OrgTrx_ID, A_Processed, C_Charge_ID, C_OrderLine_ID, C_UOM_ID, IsDescription, c_invoiceline_isprinted, M_InOutLine_ID, M_RMALine_ID, PriceLimit, c_invoiceline_processed, Ref_InvoiceLine_ID, RRAmt, RRStartDate, S_ResourceAssignment_ID, C_InvoiceLine_User1_ID, C_InvoiceLine_User2_ID, C_UOM_AD_Org_ID, CostingPrecision, c_uom_description, c_uom_isactive, c_uom_isdefault, c_uom_name, StdPrecision, UOMType, X12DE355, C_Invoice_AD_Org_ID, C_Invoice_AD_OrgTrx_ID, C_Invoice_AD_User_ID, C_Invoice_C_Activity_ID, C_Invoice_C_BPartner_ID, C_BPartner_Location_ID, C_Invoice_C_Campaign_ID, C_Invoice_C_Charge_ID, C_ConversionType_ID, C_Currency_ID, C_DocType_ID, C_DocTypeTarget_ID, C_DunningLevel_ID, c_invoice_chargeamt, C_Order_ID, C_Payment_ID, C_PaymentTerm_ID, C_Invoice_C_Project_ID, c_invoice_created, C_Invoice_CreatedBy, DateAcct, DateInvoiced, DateOrdered, DatePrinted, c_invoice_description, DocAction, DocStatus, DocumentNo, DunningGrace, GenerateTo, GrandTotal, InvoiceCollectionType, c_invoice_isactive, IsApproved, IsDiscountPrinted, IsInDispute, IsPaid, IsPayScheduleValid, c_invoice_isprinted, c_invoice_isselfservice, IsSOTrx, c_invoice_istaxincluded, IsTransferred, M_PriceList_ID, M_RMA_ID, PaymentRule, POReference, Posted, ProcessedOn, Processing, Ref_Invoice_ID, Reversal_ID, SalesRep_ID, SendEMail, TotalLines, c_invoice_updated, C_Invoice_UpdatedBy, C_Invoice_User1_ID, C_Invoice_User2_ID, 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, IsTaxExempt, c_tax_name, Parent_Tax_ID, Rate, RequiresTaxCertificate, SOPOType, To_Country_ID, To_Region_ID, ValidFrom, M_Product_AD_Org_ID, Classification, m_product_copyfrom, m_product_created, M_Product_CreatedBy, C_RevenueRecognition_ID, C_SubscriptionType_ID, M_Product_C_TaxCategory_ID, DescriptionURL, Discontinued, DiscontinuedAt, Group1, Group2, GuaranteeDays, GuaranteeDaysMin, Help, m_product_isactive, IsBOM, IsDropShip, IsExcludeAutoDelivery, IsInvoicePrintDetails, IsPickListPrintDetails, IsPurchased, m_product_isselfservice, IsSold, IsStocked, m_product_issummary, IsVerified, IsWebStoreFeatured, LowLevel, M_Product_M_AttributeSet_ID, M_Product_M_ASI_ID, M_FreightCategory_ID, M_Locator_ID, M_Product_M_Prod_Category_ID, m_product_processing, ProductType, R_MailText_ID, M_Product_SalesRep_ID, S_ExpenseType_ID, ShelfDepth, ShelfHeight, ShelfWidth, M_Product_S_Resource_ID, UnitsPerPack, UnitsPerPallet, m_product_updated, M_Product_UpdatedBy, VersionNo, Volume, Weight, C_Charge_AD_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_BP_Product_AD_Org_ID, C_BP_Product_C_BPartner_ID, c_bp_product_created, C_BP_Product_CreatedBy, c_bp_product_description, c_bp_product_isactive, IsManufacturer, Manufacturer, QualityRating, ShelfLifeMinDays, ShelfLifeMinPct, c_bp_product_updated, C_BP_Product_UpdatedBy, VendorCategory, S_RAssignment_AD_Org_ID, AssignDateFrom, AssignDateTo, s_rassignment_created, s_rassignment_createby, s_rassignment_isactive, IsConfirmed, s_rassignment_name, s_rassignment_qty, S_RAssignment_S_Resource_ID, s_rassignment_updated, S_RAssignment_UpdatedBy, M_ASI_AD_Org_ID, m_asi_created, M_ASI_CreatedBy, M_ASI_Description, m_asi_isactive, m_asi_updated, M_ASI_UpdatedBy) AS SELECT il.ad_client_id AS
;
-- Nov 28, 2021, 11:19:17 PM CET
CREATE OR REPLACE VIEW C_InvoiceLine_v(AD_Client_ID, AD_Org_ID, C_InvoiceLine_ID, C_Invoice_ID, SalesRep_ID, C_BPartner_ID, M_Product_ID, DocumentNo, DateInvoiced, DateAcct, IsSOTrx, DocStatus, LineNetAmt, LineListAmt, LineLimitAmt, LineDiscountAmt, LineOverLimitAmt, QtyInvoiced, QtyEntered, Line, C_OrderLine_ID, C_UOM_ID, C_Campaign_ID, C_Project_ID, C_Activity_ID, C_ProjectPhase_ID, C_ProjectTask_ID) AS SELECT il.ad_client_id AS AD_Client_ID, il.ad_org_id AS AD_Org_ID, il.c_invoiceline_id AS C_InvoiceLine_ID, i.c_invoice_id AS C_Invoice_ID, i.salesrep_id AS SalesRep_ID, i.c_bpartner_id AS C_BPartner_ID, il.m_product_id AS M_Product_ID, i.documentno AS DocumentNo, i.dateinvoiced AS DateInvoiced, i.dateacct AS DateAcct, i.issotrx AS IsSOTrx, i.docstatus AS DocStatus, currencyround(i.multiplier * il.linenetamt, i.c_currency_id, 'N') AS LineNetAmt, currencyround(i.multiplier * il.pricelist * il.qtyinvoiced, i.c_currency_id, 'N') AS LineListAmt, CASE WHEN COALESCE(il.pricelimit, 0) = 0 THEN currencyround(i.multiplier * il.linenetamt, i.c_currency_id, 'N') ELSE currencyround(i.multiplier * il.pricelimit * il.qtyinvoiced, i.c_currency_id, 'N') END AS LineLimitAmt, currencyround(i.multiplier * il.pricelist * il.qtyinvoiced - il.linenetamt, i.c_currency_id, 'N') AS LineDiscountAmt, CASE WHEN COALESCE(il.pricelimit, 0) = 0 THEN 0 ELSE currencyround(i.multiplier * il.linenetamt - il.pricelimit * il.qtyinvoiced, i.c_currency_id, 'N') END AS LineOverLimitAmt, il.qtyinvoiced AS QtyInvoiced, il.qtyentered AS QtyEntered, il.line AS Line, il.c_orderline_id AS C_OrderLine_ID, il.c_uom_id AS C_UOM_ID, il.c_campaign_id AS C_Campaign_ID, il.c_project_id AS C_Project_ID, il.c_activity_id AS C_Activity_ID, il.c_projectphase_id AS C_ProjectPhase_ID, il.c_projecttask_id AS C_ProjectTask_ID FROM c_invoice_v i, c_invoiceline il WHERE i.c_invoice_id = il.c_invoice_id
;
-- Nov 28, 2021, 11:19:17 PM CET
CREATE OR REPLACE VIEW C_Invoice_v(C_Invoice_ID, AD_Client_ID, AD_Org_ID, IsActive, Created, CreatedBy, Updated, UpdatedBy, IsSOTrx, DocumentNo, DocStatus, DocAction, Processing, Processed, C_DocType_ID, C_DocTypeTarget_ID, C_Order_ID, Description, IsApproved, IsTransferred, SalesRep_ID, DateInvoiced, DatePrinted, DateAcct, C_BPartner_ID, C_BPartner_Location_ID, AD_User_ID, POReference, DateOrdered, C_Currency_ID, C_ConversionType_ID, PaymentRule, C_PaymentTerm_ID, C_Charge_ID, M_PriceList_ID, C_Campaign_ID, C_Project_ID, C_Activity_ID, IsPrinted, IsDiscountPrinted, IsPaid, IsInDispute, IsPayScheduleValid, C_InvoicePaySchedule_ID, InvoiceCollectionType, DunningGrace, ChargeAmt, TotalLines, GrandTotal, Multiplier, MultiplierAP, DocBaseType, DueDate, AD_OrgTrx_ID, C_Payment_ID, IsSelfService, Posted, ProcessedOn, Reversal_ID) AS SELECT i.c_invoice_id AS C_Invoice_ID, 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, i.issotrx AS IsSOTrx, i.documentno AS DocumentNo, i.docstatus AS DocStatus, i.docaction AS DocAction, i.processing AS Processing, i.processed AS Processed, i.c_doctype_id AS C_DocType_ID, i.c_doctypetarget_id AS C_DocTypeTarget_ID, i.c_order_id AS C_Order_ID, i.description AS Description, i.isapproved AS IsApproved, i.istransferred AS IsTransferred, i.salesrep_id AS SalesRep_ID, i.dateinvoiced AS DateInvoiced, i.dateprinted AS DatePrinted, i.dateacct AS DateAcct, i.c_bpartner_id AS C_BPartner_ID, i.c_bpartner_location_id AS C_BPartner_Location_ID, i.ad_user_id AS AD_User_ID, i.poreference AS POReference, i.dateordered AS DateOrdered, i.c_currency_id AS C_Currency_ID, i.c_conversiontype_id AS C_ConversionType_ID, i.paymentrule AS PaymentRule, i.c_paymentterm_id AS C_PaymentTerm_ID, i.c_charge_id AS C_Charge_ID, i.m_pricelist_id AS M_PriceList_ID, i.c_campaign_id AS C_Campaign_ID, i.c_project_id AS C_Project_ID, i.c_activity_id AS C_Activity_ID, i.isprinted AS IsPrinted, i.isdiscountprinted AS IsDiscountPrinted, i.ispaid AS IsPaid, i.isindispute AS IsInDispute, i.ispayschedulevalid AS IsPayScheduleValid, NULL AS C_InvoicePaySchedule_ID, i.invoicecollectiontype AS InvoiceCollectionType, i.dunninggrace AS DunningGrace, CASE WHEN charat(d.docbasetype, 3) = 'C' THEN i.chargeamt * '-1' ELSE i.chargeamt END AS ChargeAmt, CASE WHEN charat(d.docbasetype, 3) = 'C' THEN i.totallines * '-1' ELSE i.totallines END AS TotalLines, CASE WHEN charat(d.docbasetype, 3) = 'C' THEN i.grandtotal * '-1' ELSE i.grandtotal END AS GrandTotal, CASE WHEN charat(d.docbasetype, 3) = 'C' THEN -1.0 ELSE 1.0 END AS Multiplier, CASE WHEN charat(d.docbasetype, 2) = 'P' THEN -1.0 ELSE 1.0 END AS MultiplierAP, d.docbasetype AS DocBaseType, paymenttermduedate(i.c_paymentterm_id, i.dateinvoiced) AS DueDate, i.ad_orgtrx_id AS AD_OrgTrx_ID, i.c_payment_id AS C_Payment_ID, i.isselfservice AS IsSelfService, i.posted AS Posted, i.processedon AS ProcessedOn, i.reversal_id AS Reversal_ID FROM c_invoice i JOIN c_doctype d ON i.c_doctype_id = d.c_doctype_id WHERE i.ispayschedulevalid <> 'Y' UNION SELECT i.c_invoice_id AS C_Invoice_ID, 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, i.issotrx AS IsSOTrx, i.documentno AS DocumentNo, i.docstatus AS DocStatus, i.docaction AS DocAction, i.processing AS Processing, i.processed AS Processed, i.c_doctype_id AS C_DocType_ID, i.c_doctypetarget_id AS C_DocTypeTarget_ID, i.c_order_id AS C_Order_ID, i.description AS Description, i.isapproved AS IsApproved, i.istransferred AS IsTransferred, i.salesrep_id AS SalesRep_ID, i.dateinvoiced AS DateInvoiced, i.dateprinted AS DatePrinted, i.dateacct AS DateAcct, i.c_bpartner_id AS C_BPartner_ID, i.c_bpartner_location_id AS C_BPartner_Location_ID, i.ad_user_id AS AD_User_ID, i.poreference AS POReference, i.dateordered AS DateOrdered, i.c_currency_id AS C_Currency_ID, i.c_conversiontype_id AS C_ConversionType_ID, i.paymentrule AS
;
-- Nov 28, 2021, 11:19:17 PM CET
CREATE OR REPLACE VIEW C_Invoice_v1(C_Invoice_ID, AD_Client_ID, AD_Org_ID, IsActive, Created, CreatedBy, Updated, UpdatedBy, IsSOTrx, DocumentNo, DocStatus, DocAction, Processing, Processed, C_DocType_ID, C_DocTypeTarget_ID, C_Order_ID, Description, IsApproved, IsTransferred, SalesRep_ID, DateInvoiced, DatePrinted, DateAcct, C_BPartner_ID, C_BPartner_Location_ID, AD_User_ID, POReference, DateOrdered, C_Currency_ID, C_ConversionType_ID, PaymentRule, C_PaymentTerm_ID, C_Charge_ID, M_PriceList_ID, C_Campaign_ID, C_Project_ID, C_Activity_ID, IsPrinted, IsDiscountPrinted, IsPaid, IsInDispute, IsPayScheduleValid, C_InvoicePaySchedule_ID, InvoiceCollectionType, ChargeAmt, TotalLines, GrandTotal, Multiplier, MultiplierAP, DocBaseType) AS SELECT i.c_invoice_id AS C_Invoice_ID, 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, i.issotrx AS IsSOTrx, i.documentno AS DocumentNo, i.docstatus AS DocStatus, i.docaction AS DocAction, i.processing AS Processing, i.processed AS Processed, i.c_doctype_id AS C_DocType_ID, i.c_doctypetarget_id AS C_DocTypeTarget_ID, i.c_order_id AS C_Order_ID, i.description AS Description, i.isapproved AS IsApproved, i.istransferred AS IsTransferred, i.salesrep_id AS SalesRep_ID, i.dateinvoiced AS DateInvoiced, i.dateprinted AS DatePrinted, i.dateacct AS DateAcct, i.c_bpartner_id AS C_BPartner_ID, i.c_bpartner_location_id AS C_BPartner_Location_ID, i.ad_user_id AS AD_User_ID, i.poreference AS POReference, i.dateordered AS DateOrdered, i.c_currency_id AS C_Currency_ID, i.c_conversiontype_id AS C_ConversionType_ID, i.paymentrule AS PaymentRule, i.c_paymentterm_id AS C_PaymentTerm_ID, i.c_charge_id AS C_Charge_ID, i.m_pricelist_id AS M_PriceList_ID, i.c_campaign_id AS C_Campaign_ID, i.c_project_id AS C_Project_ID, i.c_activity_id AS C_Activity_ID, i.isprinted AS IsPrinted, i.isdiscountprinted AS IsDiscountPrinted, i.ispaid AS IsPaid, i.isindispute AS IsInDispute, i.ispayschedulevalid AS IsPayScheduleValid, NULLIF(1.0,1.0) AS C_InvoicePaySchedule_ID, i.invoicecollectiontype AS InvoiceCollectionType, CASE WHEN charat(d.docbasetype, 3) = 'C' THEN i.chargeamt * '-1' ELSE i.chargeamt END AS ChargeAmt, CASE WHEN charat(d.docbasetype, 3) = 'C' THEN i.totallines * '-1' ELSE i.totallines END AS TotalLines, CASE WHEN charat(d.docbasetype, 3) = 'C' THEN i.grandtotal * '-1' ELSE i.grandtotal END AS GrandTotal, CASE WHEN charat(d.docbasetype, 3) = 'C' THEN -1 ELSE 1 END AS Multiplier, CASE WHEN charat(d.docbasetype, 2) = 'P' THEN -1 ELSE 1 END AS MultiplierAP, d.docbasetype AS DocBaseType FROM c_invoice i JOIN c_doctype d ON i.c_doctype_id = d.c_doctype_id
;
-- Nov 28, 2021, 11:19:17 PM CET
CREATE OR REPLACE VIEW C_Order_Header_vt(AD_Client_ID, AD_Org_ID, IsActive, Created, CreatedBy, Updated, UpdatedBy, AD_Language, C_Order_ID, IsSOTrx, DocumentNo, DocStatus, C_DocType_ID, C_BPartner_ID, BPValue, BPTaxID, NAICS, DUNS, Org_Location_ID, TaxID, M_Warehouse_ID, Warehouse_Location_ID, DocumentType, DocumentTypeNote, SalesRep_ID, SalesRep_Name, DateOrdered, DatePromised, BPGreeting, Name, Name2, BPContactGreeting, Title, Phone, ContactName, C_Location_ID, Postal, ReferenceNo, Bill_BPartner_ID, Bill_Location_ID, Bill_User_ID, Bill_BPValue, Bill_BPTaxID, Bill_Name, Bill_Name2, Bill_Title, Bill_Phone, Bill_ContactName, Bill_C_Location_ID, Description, POReference, C_Currency_ID, PaymentTerm, PaymentTermNote, C_Charge_ID, ChargeAmt, TotalLines, GrandTotal, AmtInWords, M_PriceList_ID, IsTaxIncluded, Volume, Weight, C_Campaign_ID, C_Project_ID, C_Activity_ID, M_Shipper_ID, DeliveryRule, DeliveryViaRule, PriorityRule, InvoiceRule, Logo_ID, AD_OrgTrx_ID, AD_User_ID, AmountRefunded, AmountTendered, C_BPartner_Location_ID, C_CashLine_ID, C_CashPlanLine_ID, C_ConversionType_ID, C_DocTypeTarget_ID, CopyFrom, C_Payment_ID, C_PaymentTerm_ID, C_POS_ID, DateAcct, DatePrinted, DocAction, DropShip_BPartner_ID, DropShip_Location_ID, DropShip_User_ID, FreightAmt, FreightCostRule, IsApproved, IsCreditApproved, IsDelivered, IsDiscountPrinted, IsDropShip, IsInvoiced, IsPayScheduleValid, IsPrinted, IsSelected, IsSelfService, IsTransferred, Link_Order_ID, M_FreightCategory_ID, OrderType, Pay_BPartner_ID, Pay_Location_ID, PaymentRule, Posted, Processed, ProcessedOn, PromotionCode, Ref_Order_ID, SendEMail, User1_ID, User2_ID, M_Warehouse_AD_Org_ID, m_warehouse_description, m_warehouse_isactive, IsDisallowNegativeInv, IsInTransit, M_WarehouseSource_ID, m_warehouse_name, ReplenishmentClass, Separator, m_warehouse_value, C_PaymentTerm_AD_Org_ID, AfterDelivery, c_paymentterm_description, Discount, Discount2, DiscountDays, DiscountDays2, FixMonthCutoff, FixMonthDay, FixMonthOffset, GraceDays, c_paymentterm_isactive, IsDefault, IsDueFixed, IsNextBusinessDay, IsValid, NetDay, NetDays, PaymentTermUsage, m_paymentterm_value, bp_acqusitioncost, bp_actuallifetimevalue, bp_ad_language, BP_AD_OrgBP_ID, BP_AD_Org_ID, BP_BPartner_Parent_ID, BP_C_BP_Group_ID, BP_C_Dunning_ID, BP_C_Greeting_ID, BP_C_InvoiceSchedule_ID, BP_C_PaymentTerm_ID, bp_created, BP_CreatedBy, BP_C_TaxGroup_ID, bp_deliveryrule, bp_deliveryviarule, bp_description, bp_dunninggrace, bp_firstsale, bp_flatdiscount, bp_freightcostrule, bp_invoicerule, bp_isactive, bp_iscustomer, bp_isdiscountprinted, bp_isemployee, bp_ismanufacturer, bp_isonetime, bp_ispotaxexempt, bp_isprospect, bp_issalesrep, bp_issummary, bp_istaxexempt, bp_isvendor, BP_Logo_ID, BP_M_DiscountSchema_ID, BP_M_PriceList_ID, bp_numberemployees, bp_paymentrule, bp_paymentrulepo, BP_PO_DiscountSchema_ID, BP_PO_PaymentTerm_ID, BP_PO_PriceList_ID, bp_poreference, bp_potentiallifetimevalue, bp_rating, BP_SalesRep_ID, bp_salesvolume, bp_sendemail, bp_shareofcustomer, bp_shelflifeminpct, bp_so_creditlimit, bp_socreditstatus, bp_so_creditused, bp_so_description, bp_totalopenbalance, bp_updated, BP_UpdatedBy, bp_url, C_Greeting_AD_Org_ID, c_greeting_isactive, IsFirstNameOnly, c_greeting_name, BP_Location_AD_Org_ID, BP_Location_C_BPartner_ID, bp_location_created, BP_Location_CreatedBy, BP_Location_C_SalesRegion_ID, bp_location_fax, bp_location_isactive, bp_location_isbillto, bp_location_isdn, bp_location_ispayfrom, bp_location_isremitto, bp_location_isshipto, bp_location_name, bp_location_phone, bp_location_phone2, bp_location_updated, BP_Location_UpdatedBy, Address1, Address2, Address3, Address4, C_Location_AD_Org_ID, C_City_ID, C_Country_ID, City, c_location_created, C_Location_CreatedBy, C_Region_ID, c_location_isactive, RegionName, c_location_updated, C_Location_UpdatedBy, AD_User_AD_Org_ID, AD_User_AD_OrgTrx_ID, ad_user_ad_birthday, AD_User_C_BPartner_ID, AD_User_C_BPartner_Location_ID, AD_User_C_Greeting_ID, ad_user_comments, ad_user_created, AD_User_CreatedBy, ad_user_description, ad_user_email, ad_user_fax, ad_user_isactive,
;
-- Nov 28, 2021, 11:19:17 PM CET
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_ResourceAssignm
;
-- Nov 28, 2021, 11:19:17 PM CET
CREATE OR REPLACE VIEW C_PaySelection_Check_vt(AD_Client_ID, AD_Org_ID, AD_Language, C_PaySelection_ID, C_PaySelectionCheck_ID, Org_Location_ID, TaxID, C_DocType_ID, C_BPartner_ID, BPValue, BPTaxID, NAICS, DUNS, BPGreeting, Name, Name2, C_Location_ID, ReferenceNo, POReference, PayDate, PayAmt, AmtInWords, Qty, PaymentRule, DocumentNo, Logo_ID, DocumentType, DocumentTypeNote, Description, BankAccountDescription, C_BP_BankAccount_ID, C_Payment_ID, c_payselectioncheck_created, C_PaySelectionCheck_CreatedBy, c_payselectioncheck_discamt, c_payselectioncheck_isactive, IsGeneratedDraft, IsPrinted, IsReceipt, Processed, c_payselectioncheck_updated, C_PaySelectionCheck_UpdatedBy, C_PaySelection_AD_Org_ID, C_PaySel_C_BankAccount_ID, c_payselection_created, C_PaySelection_CreatedBy, c_payselection_description, c_payselection_isactive, c_payselection_isapproved, c_payselection_name, c_payselection_processed, TotalAmt, c_payselection_updated, C_PaySelection_UpdatedBy, A_City, A_Country, C_Payment_AD_Org_ID, A_EMail, A_Ident_DL, A_Name, A_State, A_Street, A_Zip, C_Activity_ID, C_Payment_C_BPartner_ID, C_Campaign_ID, C_Payment_C_Charge_ID, C_ConversionType_ID, C_Currency_ID, c_payment_chargeamt, CheckNo, C_Payment_C_Invoice_ID, C_Payment_C_Order_ID, C_PaymentBatch_ID, C_Project_ID, c_payment_created, C_Payment_CreatedBy, DateAcct, DateTrx, c_payment_discountamt, DocStatus, c_payment_documentno, c_payment_isactive, IsAllocated, IsApproved, IsDelayedCapture, IsOnline, IsOverUnderPayment, IsPrepayment, IsReconciled, c_payment_isselfservice, Micr, Orig_TrxID, OverUnderAmt, c_payment_payamt, PONum, c_payment_posted, c_payment_processed, c_payment_processedon, R_AuthCode, R_AuthCode_DC, R_AvsAddr, R_AvsZip, R_CVV2Match, Ref_Payment_ID, C_Payment_Reversal_ID, R_Info, RoutingNo, R_PnRef, R_PnRef_DC, R_RespMsg, R_Result, Swipe, TaxAmt, TenderType, TrxType, c_payment_updated, C_Payment_UpdatedBy, User1_ID, User2_ID, VoiceAuthCode, WriteOffAmt, c_bp_acqusitioncost, c_bp_actuallifetimevalue, c_bp_ad_language, C_BP_AD_OrgBP_ID, C_BP_AD_Org_ID, C_BP_BPartner_Parent_ID, C_BP_C_BP_Group_ID, C_BP_C_Dunning_ID, C_BP_C_Greeting_ID, C_BP_C_InvoiceSchedule_ID, C_BP_C_PaymentTerm_ID, c_bp_created, C_BP_CreatedBy, C_BP_C_TaxGroup_ID, c_bp_deliveryrule, c_bp_deliveryviarule, c_bp_description, c_bp_dunninggrace, c_bp_firstsale, c_bp_flatdiscount, c_bp_freightcostrule, c_bp_invoicerule, c_bp_isactive, c_bp_iscustomer, c_bp_isdiscountprinted, c_bp_isemployee, c_bp_ismanufacturer, c_bp_isonetime, c_bp_ispotaxexempt, c_bp_isprospect, c_bp_issalesrep, c_bp_issummary, c_bp_istaxexempt, c_bp_isvendor, C_BP_Logo_ID, C_BP_M_DiscountSchema_ID, C_BP_M_PriceList_ID, c_bp_numberemployees, c_bp_paymentrule, c_bp_paymentrulepo, C_BP_PO_DiscountSchema_ID, C_BP_PO_PaymentTerm_ID, C_BP_PO_PriceList_ID, c_bp_potentiallifetimevalue, c_bp_rating, C_BP_SalesRep_ID, c_bp_salesvolume, c_bp_sendemail, c_bp_shareofcustomer, c_bp_shelflifeminpct, c_bp_so_creditlimit, c_bp_socreditstatus, c_bp_so_creditused, c_bp_so_description, c_bp_totalopenbalance, c_bp_updated, C_BP_UpdatedBy, c_bp_url, C_Greeting_AD_Org_ID, c_greeting_isactive, IsFirstNameOnly, c_greeting_name, AD_OrgInfo_AD_Org_ID, AD_OrgType_ID, C_Calendar_ID, ad_orginfo_created, AD_OrgInfo_CreatedBy, DropShip_Warehouse_ID, ad_orginfo_duns, ad_orginfo_email, ad_orginfo_fax, ad_orginfo_isactive, M_Warehouse_ID, Parent_Org_ID, ad_orginfo_phone, ad_orginfo_phone2, ReceiptFooterMsg, Supervisor_ID, ad_orginfo_updated, AD_OrgInfo_UpdatedBy) AS SELECT psc.ad_client_id AS AD_Client_ID, psc.ad_org_id AS AD_Org_ID, l.ad_language AS AD_Language, psc.c_payselection_id AS C_PaySelection_ID, psc.c_payselectioncheck_id AS C_PaySelectionCheck_ID, oi.c_location_id AS Org_Location_ID, oi.taxid AS TaxID, p.c_doctype_id AS C_DocType_ID, bp.c_bpartner_id AS C_BPartner_ID, bp.value AS BPValue, bp.taxid AS BPTaxID, bp.naics AS NAICS, bp.duns AS DUNS, bpgt.greeting AS BPGreeting, bp.name AS Name, bp.name2 AS Name2, bpartnerremitlocation(bp.c_bpartner_id) AS C_Location_ID, bp.referenceno AS ReferenceNo, bp.poreference AS POReference, ps.paydate AS PayDat
;
-- Nov 28, 2021, 11:19:17 PM CET
CREATE OR REPLACE VIEW C_PaySelection_Remittance_vt(AD_Client_ID, AD_Org_ID, AD_Language, C_PaySelection_ID, C_PaySelectionLine_ID, C_PaySelectionCheck_ID, PaymentRule, Line, OpenAmt, PayAmt, DiscountAmt, DifferenceAmt, C_BPartner_ID, DocumentNo, DateInvoiced, GrandTotal, AmtInWords, C_Invoice_ID, c_payselectionline_created, C_PaySelectionLine_CreatedBy, c_payselectionline_description, c_payselectionline_isactive, IsManual, c_payselectionline_issotrx, Processed, c_payselectionline_updated, C_PaySelectionLine_UpdatedBy, C_Invoice_AD_Org_ID, AD_OrgTrx_ID, AD_User_ID, C_Activity_ID, C_BPartner_Location_ID, C_Campaign_ID, C_Charge_ID, C_ConversionType_ID, C_Currency_ID, C_DocType_ID, C_DocTypeTarget_ID, C_DunningLevel_ID, ChargeAmt, C_Payment_ID, C_PaymentTerm_ID, C_Project_ID, c_invoice_created, C_Invoice_CreatedBy, DateAcct, DateOrdered, DatePrinted, c_invoice_description, DocAction, DocStatus, DunningGrace, GenerateTo, InvoiceCollectionType, c_invoice_isactive, IsApproved, IsDiscountPrinted, IsInDispute, IsPayScheduleValid, IsPrinted, c_invoice_isselfservice, c_invoice_issotrx, IsTaxIncluded, IsTransferred, M_PriceList_ID, M_RMA_ID, c_invoice_paymentrule, POReference, Posted, ProcessedOn, Processing, Ref_Invoice_ID, Reversal_ID, SendEMail, TotalLines, c_invoice_updated, C_Invoice_UpdatedBy, User1_ID, User2_ID) AS SELECT psl.ad_client_id AS AD_Client_ID, psl.ad_org_id AS AD_Org_ID, l.ad_language AS AD_Language, psl.c_payselection_id AS C_PaySelection_ID, psl.c_payselectionline_id AS C_PaySelectionLine_ID, psl.c_payselectioncheck_id AS C_PaySelectionCheck_ID, psl.paymentrule AS PaymentRule, psl.line AS Line, psl.openamt AS OpenAmt, psl.payamt AS PayAmt, psl.discountamt AS DiscountAmt, psl.differenceamt AS DifferenceAmt, i.c_bpartner_id AS C_BPartner_ID, i.documentno AS DocumentNo, i.dateinvoiced AS DateInvoiced, i.grandtotal AS GrandTotal, i.grandtotal AS AmtInWords, psl.c_invoice_id AS C_Invoice_ID, psl.created AS c_payselectionline_created, psl.createdby AS C_PaySelectionLine_CreatedBy, psl.description AS c_payselectionline_description, psl.isactive AS c_payselectionline_isactive, psl.ismanual AS IsManual, psl.issotrx AS c_payselectionline_issotrx, psl.processed AS Processed, psl.updated AS c_payselectionline_updated, psl.updatedby AS C_PaySelectionLine_UpdatedBy, i.ad_org_id AS C_Invoice_AD_Org_ID, i.ad_orgtrx_id AS AD_OrgTrx_ID, i.ad_user_id AS AD_User_ID, i.c_activity_id AS C_Activity_ID, i.c_bpartner_location_id AS C_BPartner_Location_ID, i.c_campaign_id AS C_Campaign_ID, i.c_charge_id AS C_Charge_ID, i.c_conversiontype_id AS C_ConversionType_ID, i.c_currency_id AS C_Currency_ID, i.c_doctype_id AS C_DocType_ID, i.c_doctypetarget_id AS C_DocTypeTarget_ID, i.c_dunninglevel_id AS C_DunningLevel_ID, i.chargeamt AS ChargeAmt, i.c_payment_id AS C_Payment_ID, i.c_paymentterm_id AS C_PaymentTerm_ID, i.c_project_id AS C_Project_ID, i.created AS c_invoice_created, i.createdby AS C_Invoice_CreatedBy, i.dateacct AS DateAcct, i.dateordered AS DateOrdered, i.dateprinted AS DatePrinted, i.description AS c_invoice_description, i.docaction AS DocAction, i.docstatus AS DocStatus, i.dunninggrace AS DunningGrace, i.generateto AS GenerateTo, i.invoicecollectiontype AS InvoiceCollectionType, i.isactive AS c_invoice_isactive, i.isapproved AS IsApproved, i.isdiscountprinted AS IsDiscountPrinted, i.isindispute AS IsInDispute, i.ispayschedulevalid AS IsPayScheduleValid, i.isprinted AS IsPrinted, i.isselfservice AS c_invoice_isselfservice, i.issotrx AS c_invoice_issotrx, i.istaxincluded AS IsTaxIncluded, i.istransferred AS IsTransferred, i.m_pricelist_id AS M_PriceList_ID, i.m_rma_id AS M_RMA_ID, i.paymentrule AS c_invoice_paymentrule, i.poreference AS POReference, i.posted AS Posted, i.processedon AS ProcessedOn, i.processing AS Processing, i.ref_invoice_id AS Ref_Invoice_ID, i.reversal_id AS Reversal_ID, i.sendemail AS SendEMail, i.totallines AS TotalLines, i.updated AS c_invoice_updated, i.updatedby AS C_Invoice_UpdatedBy, i.user1_id AS User1_ID, i.user2_id AS User2_ID FROM c_payselectionline psl JOIN c_invoice i ON psl.c_invoice_id = i.c_i
;
-- Nov 28, 2021, 11:19:18 PM CET
CREATE OR REPLACE VIEW C_Project_Details_vt(AD_Client_ID, AD_Org_ID, IsActive, Created, CreatedBy, Updated, UpdatedBy, AD_Language, C_Project_ID, C_ProjectLine_ID, Line, PlannedQty, PlannedPrice, PlannedAmt, PlannedMarginAmt, CommittedAmt, M_Product_ID, Name, Description, DocumentNote, UPC, SKU, ProductValue, M_Product_Category_ID, InvoicedAmt, InvoicedQty, CommittedQty, C_Order_ID, C_OrderPO_ID, C_ProjectIssue_ID, C_ProjectPhase_ID, C_ProjectTask_ID, DoPricing, IsPrinted, c_projectline_processed, C_Project_AD_Org_ID, AD_User_ID, C_BPartner_ID, C_BPartner_Location_ID, C_BPartnerSR_ID, C_Campaign_ID, C_Currency_ID, c_project_committedamt, c_project_committedqty, c_project_copyfrom, C_PaymentTerm_ID, C_Phase_ID, C_ProjectType_ID, c_project_created, C_Project_CreatedBy, DateContract, DateFinish, c_project_description, GenerateTo, c_project_invoicedamt, c_project_invoicedqty, c_project_isactive, IsCommitCeiling, IsCommitment, c_project_issummary, M_PriceList_Version_ID, M_Warehouse_ID, c_project_name, c_project_note, c_project_plannedamt, c_project_plannedmarginamt, c_project_plannedqty, POReference, c_project_processed, c_project_processing, ProjectBalanceAmt, ProjectCategory, ProjectLineLevel, ProjInvoiceRule, C_Project_SalesRep_ID, c_project_updated, C_Project_UpdatedBy, c_project_value, M_Product_AD_Org_ID, Classification, m_product_copyfrom, m_product_created, M_Product_CreatedBy, C_RevenueRecognition_ID, C_SubscriptionType_ID, C_TaxCategory_ID, C_UOM_ID, m_product_description, DescriptionURL, Discontinued, DiscontinuedAt, Group1, Group2, GuaranteeDays, GuaranteeDaysMin, Help, ImageURL, m_product_isactive, IsDropShip, IsExcludeAutoDelivery, IsInvoicePrintDetails, IsPickListPrintDetails, IsPurchased, IsSelfService, IsSold, IsStocked, m_product_issummary, IsVerified, IsWebStoreFeatured, LowLevel, M_AttributeSet_ID, M_AttributeSetInstance_ID, M_FreightCategory_ID, M_Locator_ID, M_Product_M_Prod_Category_ID, M_Product_M_Product_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, Volume, Weight) AS SELECT pl.ad_client_id AS AD_Client_ID, pl.ad_org_id AS AD_Org_ID, pl.isactive AS IsActive, pl.created AS Created, pl.createdby AS CreatedBy, pl.updated AS Updated, pl.updatedby AS UpdatedBy, l.ad_language AS AD_Language, pj.c_project_id AS C_Project_ID, pl.c_projectline_id AS C_ProjectLine_ID, pl.line AS Line, pl.plannedqty AS PlannedQty, pl.plannedprice AS PlannedPrice, pl.plannedamt AS PlannedAmt, pl.plannedmarginamt AS PlannedMarginAmt, pl.committedamt AS CommittedAmt, pl.m_product_id AS M_Product_ID, COALESCE(pt.name, pl.description) AS Name, CASE WHEN pt.name IS NOT NULL THEN pl.description ELSE NULL END AS Description, pt.documentnote AS DocumentNote, p.upc AS UPC, p.sku AS SKU, p.value AS ProductValue, pl.m_product_category_id AS M_Product_Category_ID, pl.invoicedamt AS InvoicedAmt, pl.invoicedqty AS InvoicedQty, pl.committedqty AS CommittedQty, pl.c_order_id AS C_Order_ID, pl.c_orderpo_id AS C_OrderPO_ID, pl.c_projectissue_id AS C_ProjectIssue_ID, pl.c_projectphase_id AS C_ProjectPhase_ID, pl.c_projecttask_id AS C_ProjectTask_ID, pl.dopricing AS DoPricing, pl.isprinted AS IsPrinted, pl.processed AS c_projectline_processed, pj.ad_org_id AS C_Project_AD_Org_ID, pj.ad_user_id AS AD_User_ID, pj.c_bpartner_id AS C_BPartner_ID, pj.c_bpartner_location_id AS C_BPartner_Location_ID, pj.c_bpartnersr_id AS C_BPartnerSR_ID, pj.c_campaign_id AS C_Campaign_ID, pj.c_currency_id AS C_Currency_ID, pj.committedamt AS c_project_committedamt, pj.committedqty AS c_project_committedqty, pj.copyfrom AS c_project_copyfrom, pj.c_paymentterm_id AS C_PaymentTerm_ID, pj.c_phase_id AS C_Phase_ID, pj.c_projecttype_id AS C_ProjectType_ID, pj.created AS c_project_created, pj.createdby AS C_Project_CreatedBy, pj.datecontract AS DateContract, pj.datefinish AS DateFinish, pj.description AS c_project_description, pj.generateto AS GenerateTo, pj.invoicedamt AS c_project_invoicedamt, p
;
-- Nov 28, 2021, 11:19:18 PM CET
CREATE OR REPLACE VIEW C_Project_Header_vt(AD_Client_ID, AD_Org_ID, IsActive, Created, CreatedBy, Updated, UpdatedBy, AD_Language, C_Project_ID, Value, ProjectName, Description, Note, IsSummary, ProjectCategory, Org_Location_ID, TaxID, C_ProjectType_ID, ProjectTypeName, C_Phase_ID, ProjectPhaseName, SalesRep_ID, SalesRep_Name, C_BPartner_ID, BPValue, BPTaxID, NAICS, DUNS, BPGreeting, Name, Name2, BPContactGreeting, Title, Phone, ContactName, C_Location_ID, ReferenceNo, PaymentTerm, PaymentTermNote, POReference, C_Currency_ID, M_PriceList_Version_ID, C_Campaign_ID, PlannedAmt, PlannedQty, PlannedMarginAmt, InvoicedAmt, InvoicedQty, ProjectBalanceAmt, IsCommitment, CommittedAmt, CommittedQty, DateContract, DateFinish, IsCommitCeiling, M_Warehouse_ID, Logo_ID, AD_User_ID, C_BPartner_Location_ID, CopyFrom, C_Project_C_PaymentTerm_ID, GenerateTo, c_project_processed, c_project_processing, ProjectLineLevel, ProjInvoiceRule, c_bp_acqusitioncost, c_bp_actuallifetimevalue, c_bp_ad_language, C_BP_AD_OrgBP_ID, C_BP_AD_Org_ID, C_BP_BPartner_Parent_ID, C_BP_C_BP_Group_ID, C_BP_C_Dunning_ID, C_BP_C_Greeting_ID, C_BP_C_InvoiceSchedule_ID, C_BP_C_PaymentTerm_ID, c_bp_created, C_BP_CreatedBy, C_BP_C_TaxGroup_ID, c_bp_deliveryrule, c_bp_deliveryviarule, c_bp_description, c_bp_dunninggrace, c_bp_firstsale, c_bp_flatdiscount, c_bp_freightcostrule, c_bp_invoicerule, c_bp_isactive, c_bp_iscustomer, c_bp_isdiscountprinted, c_bp_isemployee, c_bp_ismanufacturer, c_bp_isonetime, c_bp_ispotaxexempt, c_bp_isprospect, c_bp_issalesrep, c_bp_issummary, c_bp_istaxexempt, c_bp_isvendor, C_BP_Logo_ID, C_BP_M_DiscountSchema_ID, C_BP_M_PriceList_ID, c_bp_numberemployees, c_bp_paymentrule, c_bp_paymentrulepo, C_BP_PO_DiscountSchema_ID, C_BP_PO_PaymentTerm_ID, C_BP_PO_PriceList_ID, c_bp_poreference, c_bp_potentiallifetimevalue, c_bp_rating, C_BP_SalesRep_ID, c_bp_salesvolume, c_bp_sendemail, c_bp_shareofcustomer, c_bp_shelflifeminpct, c_bp_so_creditlimit, c_bp_socreditstatus, c_bp_so_creditused, c_bp_so_description, c_bp_totalopenbalance, c_bp_updated, C_BP_UpdatedBy, c_bp_url, AD_OrgInfo_AD_Org_ID, AD_OrgType_ID, C_Calendar_ID, ad_orginfo_created, AD_OrgInfo_CreatedBy, DropShip_Warehouse_ID, ad_orginfo_duns, ad_orginfo_email, ad_orginfo_fax, ad_orginfo_isactive, AD_OrgInfo_M_Warehouse_ID, Parent_Org_ID, ad_orginfo_phone, ad_orginfo_phone2, ReceiptFooterMsg, Supervisor_ID, ad_orginfo_updated, AD_OrgInfo_UpdatedBy, C_ProjectType_AD_Org_ID, c_projecttype_description, c_projecttype_help, c_projecttype_isactive, c_projecttype_projectcategory, C_Phase_AD_Org_ID, C_Phase_C_Phase_ID, C_Phase_C_ProjectType_ID, c_phase_description, c_phase_help, c_phase_isactive, C_Phase_M_Product_ID, c_phase_seqno, StandardQty, SalesRep_AD_Org_ID, SalesRep_AD_OrgTrx_ID, salesrep_ad_birthday, SalesRep_C_BPartner_ID, SalesRep_C_BP_Location_ID, SalesRep_C_Greeting_ID, salesrep_comments, salesrep_created, SalesRep_CreatedBy, salesrep_description, salesrep_email, salesrep_fax, salesrep_isactive, salesrep_lastcontact, salesrep_lastresult, salesrep_phone, salesrep_phone2, SalesRep_Supervisor_ID, salesrep_title, salesrep_updated, SalesRep_UpdatedBy, salesrep_value, salesrep_bp_acqusitioncost, salesrep_bp_actuallifevalue, salesrep_bp_ad_language, SalesRep_BP_AD_OrgBP_ID, SalesRep_BP_AD_Org_ID, SalesRep_BP_BPartner_Parent_ID, SalesRep_BP_C_BP_Group_ID, SalesRep_BP_C_Dunning_ID, SalesRep_BP_C_Greeting_ID, SalesRep_BP_C_InvoiceSched_ID, SalesRep_BP_C_PaymentTerm_ID, salesrep_bp_created, SalesRep_BP_CreatedBy, SalesRep_BP_C_TaxGroup_ID, salesrep_bp_deliveryrule, salesrep_bp_deliveryviarule, salesrep_bp_description, salesrep_bp_dunninggrace, salesrep_bp_duns, salesrep_bp_firstsale, salesrep_bp_flatdiscount, salesrep_bp_freightcostrule, salesrep_bp_invoicerule, salesrep_bp_isactive, salesrep_bp_iscustomer, salesrep_bp_isdiscountprinted, salesrep_bp_isemployee, salesrep_bp_ismanufacturer, salesrep_bp_isonetime, salesrep_bp_ispotaxexempt, salesrep_bp_isprospect, salesrep_bp_issalesrep, salesrep_bp_issummary, salesrep_bp_istaxexempt, salesrep_bp_isvendor, SalesRep_BP_Logo_ID, SalesRep_BP_M_DiscountS
;
-- Nov 28, 2021, 11:19:18 PM CET
CREATE OR REPLACE VIEW C_RfQResponseLineQty_vt(C_RfQResponseLine_ID, C_RfQResponseLineQty_ID, C_RfQLineQty_ID, AD_Client_ID, AD_Org_ID, IsActive, Created, CreatedBy, Updated, UpdatedBy, AD_Language, C_UOM_ID, UOMSymbol, Qty, Price, Discount) AS SELECT rq.c_rfqresponseline_id AS C_RfQResponseLine_ID, rq.c_rfqresponselineqty_id AS C_RfQResponseLineQty_ID, rq.c_rfqlineqty_id AS C_RfQLineQty_ID, rq.ad_client_id AS AD_Client_ID, rq.ad_org_id AS AD_Org_ID, rq.isactive AS IsActive, rq.created AS Created, rq.createdby AS CreatedBy, rq.updated AS Updated, rq.updatedby AS UpdatedBy, l.ad_language AS AD_Language, q.c_uom_id AS C_UOM_ID, uom.uomsymbol AS UOMSymbol, q.qty AS Qty, rq.price AS Price, rq.discount AS Discount FROM c_rfqresponselineqty rq JOIN c_rfqlineqty q ON rq.c_rfqlineqty_id = q.c_rfqlineqty_id JOIN c_uom uom ON q.c_uom_id = uom.c_uom_id JOIN ad_language l ON l.issystemlanguage = 'Y' WHERE rq.isactive = 'Y' AND q.isactive = 'Y'
;
-- Nov 28, 2021, 11:19:18 PM CET
CREATE OR REPLACE VIEW C_RfQResponseLine_vt(C_RfQResponse_ID, C_RfQResponseLine_ID, C_RfQLine_ID, C_RfQResponseLineQty_ID, C_RfQLineQty_ID, AD_Client_ID, AD_Org_ID, IsActive, Created, CreatedBy, Updated, UpdatedBy, AD_Language, Line, M_Product_ID, M_AttributeSetInstance_ID, Name, Description, DocumentNote, UPC, SKU, ProductValue, Help, DateWorkStart, DeliveryDays, C_UOM_ID, UOMSymbol, Qty, Price, Discount) AS SELECT rrl.c_rfqresponse_id AS C_RfQResponse_ID, rrl.c_rfqresponseline_id AS C_RfQResponseLine_ID, rrl.c_rfqline_id AS C_RfQLine_ID, rq.c_rfqresponselineqty_id AS C_RfQResponseLineQty_ID, rq.c_rfqlineqty_id AS C_RfQLineQty_ID, rrl.ad_client_id AS AD_Client_ID, rrl.ad_org_id AS AD_Org_ID, rrl.isactive AS IsActive, rrl.created AS Created, rrl.createdby AS CreatedBy, rrl.updated AS Updated, rrl.updatedby AS UpdatedBy, l.ad_language AS AD_Language, rl.line AS Line, rl.m_product_id AS M_Product_ID, rl.m_attributesetinstance_id AS M_AttributeSetInstance_ID, COALESCE(p.name || productattribute(rl.m_attributesetinstance_id), rl.description) AS Name, CASE WHEN p.name IS NOT NULL THEN rl.description ELSE NULL END AS Description, p.documentnote AS DocumentNote, p.upc AS UPC, p.sku AS SKU, p.value AS ProductValue, rl.help AS Help, rl.dateworkstart AS DateWorkStart, rl.deliverydays AS DeliveryDays, q.c_uom_id AS C_UOM_ID, uom.uomsymbol AS UOMSymbol, q.qty AS Qty, rq.price AS Price, rq.discount AS Discount FROM c_rfqresponselineqty rq JOIN c_rfqlineqty q ON rq.c_rfqlineqty_id = q.c_rfqlineqty_id JOIN c_uom uom ON q.c_uom_id = uom.c_uom_id JOIN c_rfqresponseline rrl ON rq.c_rfqresponseline_id = rrl.c_rfqresponseline_id JOIN c_rfqline rl ON rrl.c_rfqline_id = rl.c_rfqline_id LEFT JOIN m_product p ON rl.m_product_id = p.m_product_id JOIN ad_language l ON l.issystemlanguage = 'Y' WHERE rq.isactive = 'Y' AND q.isactive = 'Y' AND rrl.isactive = 'Y' AND rl.isactive = 'Y'
;
-- Nov 28, 2021, 11:19:18 PM CET
CREATE OR REPLACE VIEW C_RfQResponse_vt(C_RfQResponse_ID, C_RfQ_ID, AD_Client_ID, AD_Org_ID, IsActive, Created, CreatedBy, Updated, UpdatedBy, AD_Language, Org_Location_ID, TaxID, Name, Description, Help, C_Currency_ID, ISO_Code, DateResponse, DateWorkStart, DeliveryDays, C_BPartner_ID, BPName, BPName2, C_BPartner_Location_ID, C_Location_ID, AD_User_ID, Title, Phone, ContactName) AS SELECT rr.c_rfqresponse_id AS C_RfQResponse_ID, rr.c_rfq_id AS C_RfQ_ID, rr.ad_client_id AS AD_Client_ID, rr.ad_org_id AS AD_Org_ID, rr.isactive AS IsActive, rr.created AS Created, rr.createdby AS CreatedBy, rr.updated AS Updated, rr.updatedby AS UpdatedBy, l.ad_language AS AD_Language, oi.c_location_id AS Org_Location_ID, oi.taxid AS TaxID, r.name AS Name, r.description AS Description, r.help AS Help, r.c_currency_id AS C_Currency_ID, c.iso_code AS ISO_Code, r.dateresponse AS DateResponse, r.dateworkstart AS DateWorkStart, r.deliverydays AS DeliveryDays, rr.c_bpartner_id AS C_BPartner_ID, bp.name AS BPName, bp.name2 AS BPName2, rr.c_bpartner_location_id AS C_BPartner_Location_ID, bpl.c_location_id AS C_Location_ID, rr.ad_user_id AS AD_User_ID, bpc.title AS Title, bpc.phone AS Phone, NULLIF(bpc.name, bp.name) AS ContactName FROM c_rfqresponse rr JOIN c_rfq r ON rr.c_rfq_id = r.c_rfq_id JOIN ad_orginfo oi ON rr.ad_org_id = oi.ad_org_id JOIN c_currency c ON r.c_currency_id = c.c_currency_id JOIN c_bpartner bp ON rr.c_bpartner_id = bp.c_bpartner_id JOIN c_bpartner_location bpl ON rr.c_bpartner_location_id = bpl.c_bpartner_location_id LEFT JOIN ad_user bpc ON rr.ad_user_id = bpc.ad_user_id JOIN ad_language l ON l.issystemlanguage = 'Y'
;
-- Nov 28, 2021, 11:19:18 PM CET
CREATE OR REPLACE VIEW DD_Order_Header_vt(AD_Client_ID, AD_Org_ID, IsActive, Created, CreatedBy, Updated, UpdatedBy, AD_Language, DD_Order_ID, C_Order_ID, IsSOTrx, DocumentNo, DocStatus, C_DocType_ID, C_BPartner_ID, BPValue, BPTaxID, NAICS, DUNS, Org_Location_ID, TaxID, M_Warehouse_ID, Warehouse_Location_ID, DocumentType, DocumentTypeNote, SalesRep_ID, SalesRep_Name, DateOrdered, DatePromised, BPGreeting, Name, Name2, BPContactGreeting, Title, Phone, ContactName, C_Location_ID, Postal, ReferenceNo, Description, POReference, C_Charge_ID, ChargeAmt, Volume, Weight, C_Campaign_ID, C_Project_ID, C_Activity_ID, M_Shipper_ID, DeliveryRule, DeliveryViaRule, PriorityRule, Logo_ID) AS SELECT o.ad_client_id AS AD_Client_ID, o.ad_org_id AS AD_Org_ID, o.isactive AS IsActive, o.created AS Created, o.createdby AS CreatedBy, o.updated AS Updated, o.updatedby AS UpdatedBy, dt.ad_language AS AD_Language, o.dd_order_id AS DD_Order_ID, o.c_order_id AS C_Order_ID, o.issotrx AS IsSOTrx, o.documentno AS DocumentNo, o.docstatus AS DocStatus, o.c_doctype_id AS C_DocType_ID, o.c_bpartner_id AS C_BPartner_ID, bp.value AS BPValue, bp.taxid AS BPTaxID, bp.naics AS NAICS, bp.duns AS DUNS, oi.c_location_id AS Org_Location_ID, oi.taxid AS TaxID, o.m_warehouse_id AS M_Warehouse_ID, wh.c_location_id AS Warehouse_Location_ID, dt.printname AS DocumentType, dt.documentnote AS DocumentTypeNote, o.salesrep_id AS SalesRep_ID, COALESCE(ubp.name, u.name) AS SalesRep_Name, o.dateordered AS DateOrdered, o.datepromised AS DatePromised, bpg.greeting AS BPGreeting, bp.name AS Name, bp.name2 AS Name2, bpcg.greeting AS BPContactGreeting, bpc.title AS Title, bpc.phone AS Phone, NULLIF(bpc.name, bp.name) AS ContactName, bpl.c_location_id AS C_Location_ID, l.postal || l.postal_add AS Postal, bp.referenceno AS ReferenceNo, o.description AS Description, o.poreference AS POReference, o.c_charge_id AS C_Charge_ID, o.chargeamt AS ChargeAmt, o.volume AS Volume, o.weight AS Weight, o.c_campaign_id AS C_Campaign_ID, o.c_project_id AS C_Project_ID, o.c_activity_id AS C_Activity_ID, o.m_shipper_id AS M_Shipper_ID, o.deliveryrule AS DeliveryRule, o.deliveryviarule AS DeliveryViaRule, o.priorityrule AS PriorityRule, COALESCE(oi.logo_id, ci.logo_id) AS Logo_ID FROM dd_order o JOIN c_doctype_trl dt ON o.c_doctype_id = dt.c_doctype_id JOIN m_warehouse wh ON o.m_warehouse_id = wh.m_warehouse_id JOIN c_bpartner bp ON o.c_bpartner_id = bp.c_bpartner_id LEFT JOIN c_greeting_trl bpg ON bp.c_greeting_id = bpg.c_greeting_id AND dt.ad_language = bpg.ad_language JOIN c_bpartner_location bpl ON o.c_bpartner_location_id = bpl.c_bpartner_location_id JOIN c_location l ON bpl.c_location_id = l.c_location_id LEFT JOIN ad_user bpc ON o.ad_user_id = bpc.ad_user_id LEFT JOIN c_greeting_trl bpcg ON bpc.c_greeting_id = bpcg.c_greeting_id AND dt.ad_language = bpcg.ad_language JOIN ad_orginfo oi ON o.ad_org_id = oi.ad_org_id JOIN ad_clientinfo ci ON o.ad_client_id = ci.ad_client_id LEFT JOIN ad_user u ON o.salesrep_id = u.ad_user_id LEFT JOIN c_bpartner ubp ON u.c_bpartner_id = ubp.c_bpartner_id
;
-- Nov 28, 2021, 11:19:18 PM CET
CREATE OR REPLACE VIEW GL_JournalLine_Acct_v(GL_JournalLine_ID, AD_Client_ID, AD_Org_ID, IsActive, Created, CreatedBy, Updated, UpdatedBy, GL_Journal_ID, Line, IsGenerated, Description, AmtSourceDr, AmtSourceCr, C_Currency_ID, C_ConversionType_ID, CurrencyRate, DateAcct, AmtAcctDr, AmtAcctCr, C_UOM_ID, Qty, C_ValidCombination_ID, C_AcctSchema_ID, Account_ID, M_Product_ID, C_BPartner_ID, AD_OrgTrx_ID, C_LocFrom_ID, C_LocTo_ID, C_SalesRegion_ID, C_Project_ID, C_Campaign_ID, User1_ID, User2_ID, IsFullyQualified, C_Activity_ID) AS SELECT gl.gl_journalline_id AS GL_JournalLine_ID, gl.ad_client_id AS AD_Client_ID, gl.ad_org_id AS AD_Org_ID, gl.isactive AS IsActive, gl.created AS Created, gl.createdby AS CreatedBy, gl.updated AS Updated, gl.updatedby AS UpdatedBy, gl.gl_journal_id AS GL_Journal_ID, gl.line AS Line, gl.isgenerated AS IsGenerated, gl.description AS Description, gl.amtsourcedr AS AmtSourceDr, gl.amtsourcecr AS AmtSourceCr, gl.c_currency_id AS C_Currency_ID, gl.c_conversiontype_id AS C_ConversionType_ID, gl.currencyrate AS CurrencyRate, gl.dateacct AS DateAcct, gl.amtacctdr AS AmtAcctDr, gl.amtacctcr AS AmtAcctCr, gl.c_uom_id AS C_UOM_ID, gl.qty AS Qty, gl.c_validcombination_id AS C_ValidCombination_ID, vc.c_acctschema_id AS C_AcctSchema_ID, vc.account_id AS Account_ID, vc.m_product_id AS M_Product_ID, vc.c_bpartner_id AS C_BPartner_ID, vc.ad_orgtrx_id AS AD_OrgTrx_ID, vc.c_locfrom_id AS C_LocFrom_ID, vc.c_locto_id AS C_LocTo_ID, vc.c_salesregion_id AS C_SalesRegion_ID, vc.c_project_id AS C_Project_ID, vc.c_campaign_id AS C_Campaign_ID, vc.user1_id AS User1_ID, vc.user2_id AS User2_ID, vc.isfullyqualified AS IsFullyQualified, vc.c_activity_id AS C_Activity_ID FROM gl_journalline gl, c_validcombination vc WHERE gl.c_validcombination_id = vc.c_validcombination_id
;
-- Nov 28, 2021, 11:19:18 PM CET
CREATE OR REPLACE VIEW M_InOut_Candidate_v(AD_Client_ID, AD_Org_ID, C_BPartner_ID, C_Order_ID, DocumentNo, DateOrdered, C_DocType_ID, POReference, Description, SalesRep_ID, M_Warehouse_ID, TotalLines) AS SELECT o.ad_client_id AS AD_Client_ID, o.ad_org_id AS AD_Org_ID, o.c_bpartner_id AS C_BPartner_ID, o.c_order_id AS C_Order_ID, o.documentno AS DocumentNo, o.dateordered AS DateOrdered, o.c_doctype_id AS C_DocType_ID, o.poreference AS POReference, o.description AS Description, o.salesrep_id AS SalesRep_ID, l.m_warehouse_id AS M_Warehouse_ID, sum((l.qtyordered - l.qtydelivered) * l.priceactual) AS TotalLines FROM c_order o JOIN c_orderline l ON o.c_order_id = l.c_order_id WHERE o.docstatus = 'CO' AND o.isdelivered = 'N' AND (o.c_doctype_id IN ( SELECT c_doctype.c_doctype_id FROM c_doctype WHERE c_doctype.docbasetype = 'SOO' AND (c_doctype.docsubtypeso NOT IN ('ON', 'OB', 'WR')))) AND o.deliveryrule <> 'M' AND (l.m_product_id IS NULL OR (EXISTS ( SELECT 1 FROM m_product p WHERE l.m_product_id = p.m_product_id AND p.isexcludeautodelivery = 'N'))) AND l.qtyordered <> l.qtydelivered AND (l.m_product_id IS NOT NULL OR l.c_charge_id IS NOT NULL) AND NOT (EXISTS ( SELECT 1 FROM m_inoutline iol JOIN m_inout io ON iol.m_inout_id = io.m_inout_id WHERE iol.c_orderline_id = l.c_orderline_id AND (io.docstatus IN ('DR', 'IN', 'IP', 'WC')))) GROUP BY o.ad_client_id, o.ad_org_id, o.c_bpartner_id, o.c_order_id, o.documentno, o.dateordered, o.c_doctype_id, o.poreference, o.description, o.salesrep_id, l.m_warehouse_id
;
-- Nov 28, 2021, 11:19:18 PM CET
CREATE OR REPLACE VIEW M_InOutConfirm_vt(AD_Client_ID, AD_Org_ID, IsActive, Created, CreatedBy, Updated, UpdatedBy, AD_Language, M_InOutConfirm_ID, DocumentNo, ConfirmType, IsApproved, IsCancelled, Description, M_InOut_ID, ShipDescription, C_BPartner_ID, C_BPartner_Location_ID, AD_User_ID, SalesRep_ID, C_DocType_ID, DocumentType, C_Order_ID, DateOrdered, MovementDate, MovementType, M_Warehouse_ID, POReference, DeliveryRule, FreightCostRule, DeliveryViaRule, M_Shipper_ID, PriorityRule, Processed) AS SELECT ioc.ad_client_id AS AD_Client_ID, ioc.ad_org_id AS AD_Org_ID, ioc.isactive AS IsActive, ioc.created AS Created, ioc.createdby AS CreatedBy, ioc.updated AS Updated, ioc.updatedby AS UpdatedBy, dt.ad_language AS AD_Language, ioc.m_inoutconfirm_id AS M_InOutConfirm_ID, ioc.documentno AS DocumentNo, ioc.confirmtype AS ConfirmType, ioc.isapproved AS IsApproved, ioc.iscancelled AS IsCancelled, ioc.description AS Description, io.m_inout_id AS M_InOut_ID, io.description AS ShipDescription, io.c_bpartner_id AS C_BPartner_ID, io.c_bpartner_location_id AS C_BPartner_Location_ID, io.ad_user_id AS AD_User_ID, io.salesrep_id AS SalesRep_ID, io.c_doctype_id AS C_DocType_ID, dt.printname AS DocumentType, io.c_order_id AS C_Order_ID, io.dateordered AS DateOrdered, io.movementdate AS MovementDate, io.movementtype AS MovementType, io.m_warehouse_id AS M_Warehouse_ID, io.poreference AS POReference, io.deliveryrule AS DeliveryRule, io.freightcostrule AS FreightCostRule, io.deliveryviarule AS DeliveryViaRule, io.m_shipper_id AS M_Shipper_ID, io.priorityrule AS PriorityRule, ioc.processed AS Processed FROM m_inoutconfirm ioc JOIN m_inout io ON ioc.m_inout_id = io.m_inout_id JOIN c_doctype_trl dt ON io.c_doctype_id = dt.c_doctype_id
;
-- Nov 28, 2021, 11:19:18 PM CET
CREATE OR REPLACE VIEW M_InOut_Header_vt(AD_Client_ID, AD_Org_ID, IsActive, Created, CreatedBy, Updated, UpdatedBy, AD_Language, M_InOut_ID, IsSOTrx, DocumentNo, DocStatus, C_DocType_ID, C_BPartner_ID, BPValue, BPTaxID, NAICS, DUNS, Org_Location_ID, TaxID, M_Warehouse_ID, Warehouse_Location_ID, DocumentType, DocumentTypeNote, C_Order_ID, MovementDate, MovementType, BPGreeting, Name, Name2, BPContactGreeting, Title, Phone, ContactName, C_Location_ID, Postal, ReferenceNo, Description, POReference, DateOrdered, Volume, Weight, M_Shipper_ID, DeliveryRule, DeliveryViaRule, PriorityRule, Logo_ID, AD_OrgTrx_ID, AD_User_ID, C_Activity_ID, C_BPartner_Location_ID, C_Campaign_ID, C_Charge_ID, ChargeAmt, C_Invoice_ID, C_Project_ID, CreateConfirm, CreateFrom, CreatePackage, DateAcct, DatePrinted, DateReceived, DocAction, DropShip_BPartner_ID, DropShip_Location_ID, DropShip_User_ID, FreightAmt, FreightCostRule, GenerateTo, IsApproved, IsDropShip, IsInDispute, m_inout_isintransit, IsPrinted, M_RMA_ID, NoPackages, PickDate, Posted, Processed, ProcessedOn, Processing, Ref_InOut_ID, Reversal_ID, M_InOut_SalesRep_ID, SendEMail, ShipDate, TrackingNo, User1_ID, User2_ID, c_bp_acqusitioncost, c_bp_actuallifetimevalue, c_bp_ad_language, C_BP_AD_OrgBP_ID, C_BP_AD_Org_ID, C_BP_BPartner_Parent_ID, C_BP_C_BP_Group_ID, C_BP_C_Dunning_ID, C_BP_C_Greeting_ID, C_BP_C_InvoiceSchedule_ID, C_BP_C_PaymentTerm_ID, c_bp_created, C_BP_CreatedBy, C_BP_C_TaxGroup_ID, c_bp_deliveryrule, c_bp_deliveryviarule, c_bp_description, c_bp_dunninggrace, c_bp_firstsale, c_bp_flatdiscount, c_bp_freightcostrule, c_bp_invoicerule, c_bp_isactive, c_bp_iscustomer, c_bp_isdiscountprinted, c_bp_isemployee, c_bp_ismanufacturer, c_bp_isonetime, c_bp_ispotaxexempt, c_bp_isprospect, c_bp_issalesrep, c_bp_issummary, c_bp_istaxexempt, c_bp_isvendor, C_BP_Logo_ID, C_BP_M_DiscountSchema_ID, C_BP_M_PriceList_ID, c_bp_numberemployees, c_bp_paymentrule, c_bp_paymentrulepo, C_BP_PO_DiscountSchema_ID, C_BP_PO_PaymentTerm_ID, C_BP_PO_PriceList_ID, c_bp_poreference, c_bp_potentiallifetimevalue, c_bp_rating, C_BP_SalesRep_ID, c_bp_salesvolume, c_bp_sendemail, c_bp_shareofcustomer, c_bp_shelflifeminpct, c_bp_so_creditlimit, c_bp_socreditstatus, c_bp_so_creditused, c_bp_so_description, c_bp_totalopenbalance, c_bp_updated, C_BP_UpdatedBy, c_bp_url, C_Greeting_AD_Org_ID, c_greeting_isactive, IsFirstNameOnly, c_greeting_name, C_BP_Location_AD_Org_ID, C_BP_Location_C_BPartner_ID, c_bp_location_created, C_BP_Location_CreatedBy, C_SalesRegion_ID, c_bp_location_fax, c_bp_location_isactive, IsBillTo, ISDN, IsPayFrom, IsRemitTo, IsShipTo, c_bp_location_name, c_bp_location_phone, c_bp_location_phone2, c_bp_location_updated, C_BP_Location_UpdatedBy, Address1, Address2, Address3, Address4, C_Location_AD_Org_ID, C_City_ID, C_Country_ID, City, c_location_created, C_Location_CreatedBy, C_Region_ID, c_location_isactive, RegionName, c_location_updated, C_Location_UpdatedBy, AD_User_AD_Org_ID, AD_User_AD_AD_OrgTrx_ID, ad_user_ad_birthday, AD_User_C_BPartner_ID, AD_User_C_BPartner_Location_ID, AD_User_C_Greeting_ID, ad_user_comments, ad_user_created, AD_User_CreatedBy, ad_user_description, ad_user_email, ad_user_fax, ad_user_isactive, ad_user_lastcontact, ad_user_lastresult, ad_user_phone2, AD_User_Supervisor_ID, ad_user_updated, AD_User_UpdatedBy, ad_user_value, C_User_Greeting_AD_Org_ID, c_user_greeting_isactive, c_user_greeting_isfnameonly, c_user_greeting_name, AD_OrgInfo_AD_Org_ID, AD_OrgType_ID, C_Calendar_ID, ad_orginfo_created, AD_OrgInfo_CreatedBy, DropShip_Warehouse_ID, ad_orginfo_duns, ad_orginfo_email, ad_orginfo_fax, ad_orginfo_isactive, AD_OrgInfo_M_Warehouse_ID, Parent_Org_ID, ad_orginfo_phone, ad_orginfo_phone2, ReceiptFooterMsg, Supervisor_ID, ad_orginfo_updated, AD_OrgInfo_UpdatedBy, M_Warehouse_AD_Org_ID, m_warehouse_description, m_warehouse__isactive, IsDisallowNegativeInv, m_warehouse_isintransit, M_WarehouseSource_ID, m_warehouse_name, ReplenishmentClass, Separator, m_warehouse_value) AS SELECT io.ad_client_id AS AD_Client_ID, io.ad_org_id AS AD_Org_ID, io.isactive AS IsActive, io.created AS
;
-- Nov 28, 2021, 11:19:18 PM CET
CREATE OR REPLACE VIEW M_InOut_LineConfirm_vt(AD_Client_ID, AD_Org_ID, IsActive, Created, CreatedBy, Updated, UpdatedBy, AD_Language, M_InOutLineConfirm_ID, M_InOutConfirm_ID, TargetQty, ConfirmedQty, DifferenceQty, ScrappedQty, Description, Processed, M_InOut_ID, M_InOutLine_ID, Line, M_Product_ID, MovementQty, UOMSymbol, QtyBackOrdered, Name, ShipDescription, DocumentNote, UPC, SKU, ProductValue, M_Locator_ID, M_Warehouse_ID, X, Y, Z, M_AttributeSetInstance_ID, M_AttributeSet_ID, SerNo, Lot, M_Lot_ID, GuaranteeDate) AS SELECT iolc.ad_client_id AS AD_Client_ID, iolc.ad_org_id AS AD_Org_ID, iolc.isactive AS IsActive, iolc.created AS Created, iolc.createdby AS CreatedBy, iolc.updated AS Updated, iolc.updatedby AS UpdatedBy, uom.ad_language AS AD_Language, iolc.m_inoutlineconfirm_id AS M_InOutLineConfirm_ID, iolc.m_inoutconfirm_id AS M_InOutConfirm_ID, iolc.targetqty AS TargetQty, iolc.confirmedqty AS ConfirmedQty, iolc.differenceqty AS DifferenceQty, iolc.scrappedqty AS ScrappedQty, iolc.description AS Description, iolc.processed AS Processed, iol.m_inout_id AS M_InOut_ID, iol.m_inoutline_id AS M_InOutLine_ID, iol.line AS Line, p.m_product_id AS M_Product_ID, iol.movementqty AS MovementQty, uom.uomsymbol AS UOMSymbol, ol.qtyordered - ol.qtydelivered AS QtyBackOrdered, COALESCE(COALESCE(pt.name, p.name), iol.description) AS Name, CASE WHEN COALESCE(pt.name, p.name) IS NOT NULL THEN iol.description ELSE NULL END AS ShipDescription, COALESCE(pt.documentnote, p.documentnote) AS DocumentNote, p.upc AS UPC, p.sku AS SKU, p.value AS ProductValue, iol.m_locator_id AS M_Locator_ID, l.m_warehouse_id AS M_Warehouse_ID, l.x AS X, l.y AS Y, l.z AS Z, iol.m_attributesetinstance_id AS M_AttributeSetInstance_ID, asi.m_attributeset_id AS M_AttributeSet_ID, asi.serno AS SerNo, asi.lot AS Lot, asi.m_lot_id AS M_Lot_ID, asi.guaranteedate AS GuaranteeDate FROM m_inoutlineconfirm iolc JOIN m_inoutline iol ON iolc.m_inoutline_id = iol.m_inoutline_id JOIN c_uom_trl uom ON iol.c_uom_id = uom.c_uom_id LEFT JOIN m_product p ON iol.m_product_id = p.m_product_id LEFT JOIN m_product_trl pt ON iol.m_product_id = pt.m_product_id AND uom.ad_language = pt.ad_language LEFT JOIN m_attributesetinstance asi ON iol.m_attributesetinstance_id = asi.m_attributesetinstance_id LEFT JOIN m_locator l ON iol.m_locator_id = l.m_locator_id LEFT JOIN c_orderline ol ON iol.c_orderline_id = ol.c_orderline_id
;
-- Nov 28, 2021, 11:19:18 PM CET
CREATE OR REPLACE VIEW M_InOutLineMA_Returned(M_InOutLine_ID, M_AttributeSetInstance_ID, AD_Client_ID, AD_Org_ID, IsActive, Created, CreatedBy, Updated, UpdatedBy, MovementQty, M_InOutLineMA_UU, DateMaterialPolicy, IsAutoGenerated, returnedqty) AS SELECT sma.m_inoutline_id AS M_InOutLine_ID, sma.m_attributesetinstance_id AS M_AttributeSetInstance_ID, sma.ad_client_id AS AD_Client_ID, sma.ad_org_id AS AD_Org_ID, sma.isactive AS IsActive, sma.created AS Created, sma.createdby AS CreatedBy, sma.updated AS Updated, sma.updatedby AS UpdatedBy, sma.movementqty AS MovementQty, sma.m_inoutlinema_uu AS M_InOutLineMA_UU, sma.datematerialpolicy AS DateMaterialPolicy, sma.isautogenerated AS IsAutoGenerated, sum(crma.movementqty) AS returnedqty FROM m_inoutlinema sma JOIN m_inoutline sl ON sma.m_inoutline_id = sl.m_inoutline_id JOIN m_inout sio ON sio.m_inout_id = sl.m_inout_id LEFT JOIN m_rmaline rl ON rl.m_inoutline_id = sl.m_inoutline_id LEFT JOIN m_inoutline crl ON rl.m_rmaline_id = crl.m_rmaline_id LEFT JOIN m_inout cr ON cr.m_inout_id = crl.m_inout_id AND NOT (cr.docstatus IN ('CO', 'RE')) LEFT JOIN m_inoutlinema crma ON crma.m_inoutline_id = crl.m_inoutline_id AND sma.m_attributesetinstance_id = crma.m_attributesetinstance_id GROUP BY sma.m_attributesetinstance_id, sma.m_inoutline_id, sma.ad_client_id, sma.ad_org_id, sma.isactive, sma.created, sma.createdby, sma.updated, sma.updatedby, sma.movementqty, sma.m_inoutlinema_uu, sma.datematerialpolicy, sma.isautogenerated
;
-- Nov 28, 2021, 11:19:18 PM CET
CREATE OR REPLACE VIEW M_InOutLineMA_vt(AD_Client_ID, AD_Org_ID, IsActive, Created, CreatedBy, Updated, UpdatedBy, M_InOut_ID, M_InOutLine_ID, Line, M_Product_ID, M_AttributeSetInstance_ID, MovementQty, M_Locator_ID) AS SELECT m.ad_client_id AS AD_Client_ID, m.ad_org_id AS AD_Org_ID, m.isactive AS IsActive, m.created AS Created, m.createdby AS CreatedBy, m.updated AS Updated, m.updatedby AS UpdatedBy, l.m_inout_id AS M_InOut_ID, m.m_inoutline_id AS M_InOutLine_ID, l.line AS Line, l.m_product_id AS M_Product_ID, m.m_attributesetinstance_id AS M_AttributeSetInstance_ID, m.movementqty AS MovementQty, l.m_locator_id AS M_Locator_ID FROM m_inoutlinema m JOIN m_inoutline l ON m.m_inoutline_id = l.m_inoutline_id UNION SELECT m_inoutline.ad_client_id AS AD_Client_ID, m_inoutline.ad_org_id AS AD_Org_ID, m_inoutline.isactive AS IsActive, m_inoutline.created AS Created, m_inoutline.createdby AS CreatedBy, m_inoutline.updated AS Updated, m_inoutline.updatedby AS UpdatedBy, m_inoutline.m_inout_id AS M_InOut_ID, m_inoutline.m_inoutline_id AS M_InOutLine_ID, m_inoutline.line AS Line, m_inoutline.m_product_id AS M_Product_ID, m_inoutline.m_attributesetinstance_id AS M_AttributeSetInstance_ID, m_inoutline.movementqty AS MovementQty, m_inoutline.m_locator_id AS M_Locator_ID FROM m_inoutline
;
-- Nov 28, 2021, 11:19:18 PM CET
CREATE OR REPLACE VIEW M_InOut_Line_vt(AD_Client_ID, AD_Org_ID, IsActive, Created, CreatedBy, Updated, UpdatedBy, AD_Language, M_InOut_ID, M_InOutLine_ID, Line, M_Product_ID, MovementQty, QtyEntered, UOMSymbol, QtyOrdered, QtyDelivered, QtyBackOrdered, Name, Description, DocumentNote, UPC, SKU, ProductValue, M_Locator_ID, M_Warehouse_ID, X, Y, Z, M_AttributeSetInstance_ID, M_AttributeSet_ID, SerNo, Lot, M_Lot_ID, GuaranteeDate, ProductDescription, ImageURL, C_Campaign_ID, C_Project_ID, C_Activity_ID, C_ProjectPhase_ID, C_ProjectTask_ID, AD_OrgTrx_ID, C_Charge_ID, ConfirmedQty, C_OrderLine_ID, M_InOutLine_C_UOM_ID, m_inoutline_isdescription, IsInvoiced, M_RMALine_ID, PickedQty, m_inoutline_processed, Ref_InOutLine_ID, ReversalLine_ID, ScrappedQty, TargetQty, M_InOutLine_User1_ID, M_InOutLine_User2_ID, M_Product_AD_Org_ID, Classification, m_product_copyfrom, m_product_created, M_Product_CreatedBy, C_RevenueRecognition_ID, C_SubscriptionType_ID, M_Product_C_TaxCategory_ID, M_Product_C_UOM_ID, DescriptionURL, Discontinued, DiscontinuedAt, Group1, Group2, GuaranteeDays, GuaranteeDaysMin, Help, m_product_isactive, IsBOM, IsDropShip, IsExcludeAutoDelivery, IsInvoicePrintDetails, IsPickListPrintDetails, IsPurchased, m_product_isselfservice, IsSold, IsStocked, m_product_issummary, IsVerified, IsWebStoreFeatured, LowLevel, M_Product_M_AttributeSet_ID, M_Product_M_ASI_ID, M_FreightCategory_ID, M_Product_M_Locator_ID, M_Product_M_Prod_Category_ID, m_product_processing, ProductType, R_MailText_ID, M_Product_SalesRep_ID, S_ExpenseType_ID, ShelfDepth, ShelfHeight, ShelfWidth, M_Product_S_Resource_ID, UnitsPerPack, UnitsPerPallet, m_product_updated, M_Product_UpdatedBy, VersionNo, Volume, Weight, C_UOM_AD_Org_ID, CostingPrecision, c_uom_description, c_uom_isactive, c_uom_isdefault, c_uom_name, StdPrecision, UOMType, X12DE355, M_ASI_AD_Org_ID, m_asi_created, M_ASI_CreatedBy, M_ASI_Description, m_asi_isactive, m_asi_updated, M_ASI_UpdatedBy, M_Locator_AD_Org_ID, m_locator_isactive, IsDefault, PriorityNo, m_locator_value, C_OrderLine_AD_Org_ID, C_OrderLine_AD_OrgTrx_ID, C_OrderLine_C_Activity_ID, C_OrderLine_C_BPartner_ID, C_OrderLine_C_BP_Location_ID, C_OrderLine_C_Charge_ID, C_OrderLine_C_Currency_ID, C_Order_ID, C_OrderLine_C_Project_ID, C_OrderLine_C_ProjectPhase_ID, C_OrderLine_C_ProjectTask_ID, c_orderline_created, C_OrderLine_CreatedBy, C_OrderLine_C_Tax_ID, C_OrderLine_C_UOM_ID, DateDelivered, DateInvoiced, DateOrdered, c_orderline_datepromised, c_orderline_description, Discount, c_orderline_freightamt, c_orderline_isactive, c_orderline_isdescription, c_orderline_line, LineNetAmt, Link_OrderLine_ID, C_OrderLine_M_ASI_ID, C_OrderLine_M_Product_ID, M_Promotion_ID, C_OrderLine_M_Shipper_ID, C_OrderLine_Warehouse_ID, PriceActual, PriceCost, PriceEntered, PriceLimit, PriceList, c_orderline_processed, c_orderline_qtyentered, QtyInvoiced, QtyLostSales, QtyReserved, Ref_OrderLine_ID, RRAmt, RRStartDate, S_ResourceAssignment_ID, c_orderline_updated, C_OrderLine_UpdatedBy, C_OrderLine_User1_ID, C_OrderLine_User2_ID, 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) AS SELECT iol.ad_client_id AS AD_Client_ID, iol.ad_org_id AS AD_Org_ID, iol.isactive AS IsActive, iol.created AS Created, iol.createdby AS CreatedBy, iol.updated AS Updated, iol.updatedby AS UpdatedBy, uomt.ad_language AS AD_Language, iol.m_inout_id AS M_InOut_ID, iol.m_inoutline_id AS M_InOutLine_ID, iol.line AS Line, pt.m_product_id AS M_Product_ID, CASE WHEN iol.movementqty <> 0 OR iol.m_product_id IS NOT NULL THEN iol.movementqty ELSE NULL END AS MovementQty, CASE WHEN iol.qtyentered <> 0 OR iol.m_product_id IS NOT NULL THEN iol.qtyentered ELSE NULL END AS QtyEntered, CASE WHEN iol.movementqty <> 0 OR iol.m_product_id IS NOT NULL THEN uomt.uomsymbol ELSE NULL END AS UOMSymbol, ol.qtyordered AS QtyOrdered, ol.qtydelivered AS QtyDelivered, CASE WHEN iol.movementqty <> 0 OR iol.m_product_id IS NOT NULL THEN ol.qtyordered - ol.qtydel
;
-- Nov 28, 2021, 11:19:18 PM CET
CREATE OR REPLACE VIEW M_Movement_Candidate_v(AD_Client_ID, AD_Org_ID, C_BPartner_ID, DD_Order_ID, DocumentNo, DateOrdered, C_DocType_ID, POReference, Description, SalesRep_ID, M_Locator_ID, M_LocatorTo_ID) AS SELECT o.ad_client_id AS AD_Client_ID, o.ad_org_id AS AD_Org_ID, o.c_bpartner_id AS C_BPartner_ID, o.dd_order_id AS DD_Order_ID, o.documentno AS DocumentNo, o.dateordered AS DateOrdered, o.c_doctype_id AS C_DocType_ID, o.poreference AS POReference, o.description AS Description, o.salesrep_id AS SalesRep_ID, l.m_locator_id AS M_Locator_ID, l.m_locatorto_id AS M_LocatorTo_ID FROM dd_order o JOIN dd_orderline l ON o.dd_order_id = l.dd_order_id WHERE o.docstatus = 'CO' AND o.isdelivered = 'N' AND (o.c_doctype_id IN ( SELECT c_doctype.c_doctype_id FROM c_doctype WHERE c_doctype.docbasetype = 'DOO')) AND o.deliveryrule <> 'M' AND (l.m_product_id IS NULL OR (EXISTS ( SELECT 1 FROM m_product p WHERE l.m_product_id = p.m_product_id AND p.isexcludeautodelivery = 'N'))) AND l.qtyordered <> l.qtydelivered AND l.confirmedqty > 0 AND o.isdropship = 'N' AND (l.m_product_id IS NOT NULL OR l.c_charge_id IS NOT NULL) AND NOT (EXISTS ( SELECT 1 FROM m_movementline iol JOIN m_movement io ON iol.m_movement_id = io.m_movement_id WHERE iol.dd_orderline_id = l.dd_orderline_id AND (io.docstatus IN ('IP', 'WC')))) GROUP BY o.ad_client_id, o.ad_org_id, o.c_bpartner_id, o.dd_order_id, o.documentno, o.dateordered, o.c_doctype_id, o.poreference, o.description, o.salesrep_id, l.m_locator_id, l.m_locatorto_id
;
-- Nov 28, 2021, 11:19:18 PM CET
CREATE OR REPLACE VIEW M_MovementLineMA_vt(AD_Client_ID, AD_Org_ID, IsActive, Created, CreatedBy, Updated, UpdatedBy, M_Movement_ID, M_MovementLine_ID, Line, M_Product_ID, M_AttributeSetInstance_ID, MovementQty, M_Locator_ID, M_LocatorTo_ID) AS SELECT m.ad_client_id AS AD_Client_ID, m.ad_org_id AS AD_Org_ID, m.isactive AS IsActive, m.created AS Created, m.createdby AS CreatedBy, m.updated AS Updated, m.updatedby AS UpdatedBy, l.m_movement_id AS M_Movement_ID, m.m_movementline_id AS M_MovementLine_ID, l.line AS Line, l.m_product_id AS M_Product_ID, m.m_attributesetinstance_id AS M_AttributeSetInstance_ID, m.movementqty AS MovementQty, l.m_locator_id AS M_Locator_ID, l.m_locatorto_id AS M_LocatorTo_ID FROM m_movementlinema m JOIN m_movementline l ON m.m_movementline_id = l.m_movementline_id UNION SELECT m_movementline.ad_client_id AS AD_Client_ID, m_movementline.ad_org_id AS AD_Org_ID, m_movementline.isactive AS IsActive, m_movementline.created AS Created, m_movementline.createdby AS CreatedBy, m_movementline.updated AS Updated, m_movementline.updatedby AS UpdatedBy, m_movementline.m_movement_id AS M_Movement_ID, m_movementline.m_movementline_id AS M_MovementLine_ID, m_movementline.line AS Line, m_movementline.m_product_id AS M_Product_ID, m_movementline.m_attributesetinstance_id AS M_AttributeSetInstance_ID, m_movementline.movementqty AS MovementQty, m_movementline.m_locator_id AS M_Locator_ID, m_movementline.m_locatorto_id AS M_LocatorTo_ID FROM m_movementline
;
-- Nov 28, 2021, 11:19:18 PM CET
CREATE OR REPLACE VIEW M_PackageLines_Avail_v(AD_Client_ID, AD_Org_ID, M_InOut_ID, M_InOutLine_ID, Line, Qty, M_Product_ID, ProductName, uom) AS SELECT DISTINCT iol.ad_client_id AS AD_Client_ID, iol.ad_org_id AS AD_Org_ID, iol.m_inout_id AS M_InOut_ID, iol.m_inoutline_id AS M_InOutLine_ID, iol.line AS Line, iol.qtyentered - COALESCE(( SELECT sum(m_packageline.qty) AS sum FROM m_packageline WHERE m_packageline.m_inoutline_id = iol.m_inoutline_id), 0) AS Qty, iol.m_product_id AS M_Product_ID, p.name AS ProductName, uom.name AS uom FROM m_inoutline iol LEFT JOIN m_packageline mpl ON iol.m_inoutline_id = mpl.m_inoutline_id JOIN m_product p ON iol.m_product_id = p.m_product_id JOIN c_uom uom ON iol.c_uom_id = uom.c_uom_id JOIN ad_clientinfo ci ON ci.ad_client_id = iol.ad_client_id WHERE p.ispicklistprintdetails = 'N' AND iol.m_product_id <> COALESCE(ci.m_productfreight_id, 0) AND (iol.qtyentered - COALESCE(( SELECT sum(m_packageline.qty) AS sum FROM m_packageline WHERE m_packageline.m_inoutline_id = iol.m_inoutline_id), 0)) <> 0 UNION SELECT DISTINCT iol.ad_client_id AS AD_Client_ID, iol.ad_org_id AS AD_Org_ID, iol.m_inout_id AS M_InOut_ID, iol.m_inoutline_id AS M_InOutLine_ID, iol.line + pbom.line / 100 AS Line, iol.qtyentered * pbom.bomqty - COALESCE(( SELECT sum(m_packageline.qty) AS sum FROM m_packageline WHERE m_packageline.m_product_id = p2.m_product_id AND (m_packageline.m_package_id IN ( SELECT m_package.m_package_id FROM m_package WHERE m_package.m_inout_id = iol.m_inout_id))), 0) AS Qty, pbom.m_productbom_id AS M_Product_ID, p2.name AS ProductName, uom.name AS uom FROM m_inoutline iol LEFT JOIN m_packageline mpl ON iol.m_inoutline_id = mpl.m_inoutline_id JOIN m_product p ON iol.m_product_id = p.m_product_id JOIN m_product_bom_old pbom ON p.m_product_id = pbom.m_product_id JOIN m_product p2 ON pbom.m_productbom_id = p2.m_product_id JOIN c_uom uom ON iol.c_uom_id = uom.c_uom_id WHERE p.isbom = 'Y' AND p.isverified = 'Y' AND p.ispicklistprintdetails = 'Y' AND (iol.qtyentered * pbom.bomqty - COALESCE(( SELECT sum(m_packageline.qty) AS sum FROM m_packageline WHERE m_packageline.m_product_id = p2.m_product_id AND (m_packageline.m_package_id IN ( SELECT m_package.m_package_id FROM m_package WHERE m_package.m_inout_id = iol.m_inout_id))), 0)) <> 0 ORDER BY 1, 2, 3, 5
;
-- Nov 28, 2021, 11:19:18 PM CET
CREATE OR REPLACE VIEW PP_Order_BOM_Header_vt(AD_Client_ID, AD_Org_ID, IsActive, Created, CreatedBy, Updated, UpdatedBy, AD_Language, PP_Order_ID, DocumentNo, DocStatus, C_DocType_ID, Org_Location_ID, TaxID, M_Warehouse_ID, Warehouse_Location_ID, DocumentType, DocumentTypeNote, Planner_ID, SalesRep_Name, DateStart, DateStartSchedule, FloatAfter, FloatBefored, Line, Lot, SerNo, C_UOM_ID, S_Resource_ID, PP_Product_BOM_ID, AD_Workflow_ID, Assay, C_OrderLine_ID, PriorityRule, QtyBatchSize, QtyBatchs, QtyDelivered, QtyEntered, QtyOrdered, DateConfirm, DateDelivered, DateFinish, DateFinishSchedule, DateOrdered, DatePromised, QtyReject, QtyReserved, QtyScrap, Yield, C_Campaign_ID, C_Project_ID, C_Activity_ID, BOMType, BOMUse, Description, Help, M_AttributeSetInstance_ID, M_Product_ID, Name, Revision, ValidFrom, ValidTo, Logo_ID) AS SELECT o.ad_client_id AS AD_Client_ID, o.ad_org_id AS AD_Org_ID, o.isactive AS IsActive, o.created AS Created, o.createdby AS CreatedBy, o.updated AS Updated, o.updatedby AS UpdatedBy, obt.ad_language AS AD_Language, o.pp_order_id AS PP_Order_ID, o.documentno AS DocumentNo, o.docstatus AS DocStatus, o.c_doctype_id AS C_DocType_ID, oi.c_location_id AS Org_Location_ID, oi.taxid AS TaxID, o.m_warehouse_id AS M_Warehouse_ID, wh.c_location_id AS Warehouse_Location_ID, dt.printname AS DocumentType, dt.documentnote AS DocumentTypeNote, o.planner_id AS Planner_ID, u.name AS SalesRep_Name, o.datestart AS DateStart, o.datestartschedule AS DateStartSchedule, o.floatafter AS FloatAfter, o.floatbefored AS FloatBefored, o.line AS Line, o.lot AS Lot, o.serno AS SerNo, o.c_uom_id AS C_UOM_ID, o.s_resource_id AS S_Resource_ID, o.pp_product_bom_id AS PP_Product_BOM_ID, o.ad_workflow_id AS AD_Workflow_ID, o.assay AS Assay, o.c_orderline_id AS C_OrderLine_ID, o.priorityrule AS PriorityRule, o.qtybatchsize AS QtyBatchSize, o.qtybatchs AS QtyBatchs, o.qtydelivered AS QtyDelivered, o.qtyentered AS QtyEntered, o.qtyordered AS QtyOrdered, o.dateconfirm AS DateConfirm, o.datedelivered AS DateDelivered, o.datefinish AS DateFinish, o.datefinishschedule AS DateFinishSchedule, o.dateordered AS DateOrdered, o.datepromised AS DatePromised, o.qtyreject AS QtyReject, o.qtyreserved AS QtyReserved, o.qtyscrap AS QtyScrap, o.yield AS Yield, o.c_campaign_id AS C_Campaign_ID, o.c_project_id AS C_Project_ID, o.c_activity_id AS C_Activity_ID, ob.bomtype AS BOMType, ob.bomuse AS BOMUse, obt.description AS Description, obt.help AS Help, ob.m_attributesetinstance_id AS M_AttributeSetInstance_ID, ob.m_product_id AS M_Product_ID, obt.name AS Name, ob.revision AS Revision, ob.validfrom AS ValidFrom, ob.validto AS ValidTo, COALESCE(oi.logo_id, ci.logo_id) AS Logo_ID FROM pp_order o JOIN c_doctype_trl dt ON o.c_doctype_id = dt.c_doctype_id JOIN pp_order_bom ob ON ob.pp_order_id = o.pp_order_id JOIN pp_order_bom_trl obt ON obt.pp_order_bom_id = ob.pp_order_bom_id JOIN m_warehouse wh ON o.m_warehouse_id = wh.m_warehouse_id JOIN ad_orginfo oi ON o.ad_org_id = oi.ad_org_id JOIN ad_clientinfo ci ON o.ad_client_id = ci.ad_client_id LEFT JOIN ad_user u ON o.planner_id = u.ad_user_id
;
-- Nov 28, 2021, 11:19:18 PM CET
CREATE OR REPLACE VIEW PP_Order_BOMLine_vt(AD_Client_ID, AD_Org_ID, IsActive, Created, CreatedBy, Updated, UpdatedBy, AD_Language, Description, Feature, M_Product_ID, BackflushGroup, C_UOM_ID, ComponentType, DateDelivered, Forecast, Help, IsCritical, IssueMethod, LeadTimeOffset, Line, M_AttributeSetInstance_ID, M_ChangeNotice_ID, M_Locator_ID, M_Warehouse_ID, PP_Order_BOM_ID, PP_Order_BOMLine_ID, PP_Order_ID, QtyDelivered, QtyPost, QtyReject, QtyScrap, Scrap, ValidFrom, ValidTo, Assay, AD_User_ID, QtyBatchs, QtyRequiered, QtyReserved, QtyAvailable, QtyOnHand, QtyBOM, IsQtyPercentage, QtyBatch, QtyBatchSize) AS SELECT obl.ad_client_id AS AD_Client_ID, obl.ad_org_id AS AD_Org_ID, obl.isactive AS IsActive, obl.created AS Created, obl.createdby AS CreatedBy, obl.updated AS Updated, obl.updatedby AS UpdatedBy, oblt.ad_language AS AD_Language, oblt.description AS Description, obl.feature AS Feature, obl.m_product_id AS M_Product_ID, obl.backflushgroup AS BackflushGroup, obl.c_uom_id AS C_UOM_ID, obl.componenttype AS ComponentType, obl.datedelivered AS DateDelivered, obl.forecast AS Forecast, oblt.help AS Help, obl.iscritical AS IsCritical, obl.issuemethod AS IssueMethod, obl.leadtimeoffset AS LeadTimeOffset, obl.line AS Line, obl.m_attributesetinstance_id AS M_AttributeSetInstance_ID, obl.m_changenotice_id AS M_ChangeNotice_ID, obl.m_locator_id AS M_Locator_ID, obl.m_warehouse_id AS M_Warehouse_ID, obl.pp_order_bom_id AS PP_Order_BOM_ID, obl.pp_order_bomline_id AS PP_Order_BOMLine_ID, obl.pp_order_id AS PP_Order_ID, obl.qtydelivered AS QtyDelivered, obl.qtypost AS QtyPost, obl.qtyreject AS QtyReject, obl.qtyscrap AS QtyScrap, obl.scrap AS Scrap, obl.validfrom AS ValidFrom, obl.validto AS ValidTo, obl.assay AS Assay, obl.ad_user_id AS AD_User_ID, o.qtybatchs AS QtyBatchs, round(obl.qtyrequiered, 4) AS QtyRequiered, round(bomqtyreserved(obl.m_product_id, obl.m_warehouse_id, 0), 4) AS QtyReserved, round(bomqtyavailable(obl.m_product_id, obl.m_warehouse_id, 0), 4) AS QtyAvailable, round(bomqtyonhand(obl.m_product_id, obl.m_warehouse_id, 0), 4) AS QtyOnHand, round(obl.qtybom, 4) AS QtyBOM, obl.isqtypercentage AS IsQtyPercentage, round(obl.qtybatch, 4) AS QtyBatch, CASE WHEN o.qtybatchs = 0 THEN 1 ELSE round(obl.qtyrequiered / o.qtybatchs, 4) END AS QtyBatchSize FROM pp_order_bomline obl JOIN pp_order o ON o.pp_order_id = obl.pp_order_id LEFT JOIN pp_order_bomline_trl oblt ON oblt.pp_order_bomline_id = obl.pp_order_bomline_id
;
-- Nov 28, 2021, 11:19:18 PM CET
CREATE OR REPLACE VIEW PP_Order_Header_vt(AD_Client_ID, AD_Org_ID, IsActive, Created, CreatedBy, Updated, UpdatedBy, AD_Language, PP_Order_ID, DocumentNo, DocStatus, C_DocType_ID, Org_Location_ID, TaxID, M_Warehouse_ID, Warehouse_Location_ID, DocumentType, DocumentTypeNote, Planner_ID, SalesRep_Name, DateStart, DateStartSchedule, FloatAfter, FloatBefored, Line, Lot, SerNo, Description, M_Product_ID, M_AttributeSetInstance_ID, C_UOM_ID, S_Resource_ID, PP_Product_BOM_ID, AD_Workflow_ID, Assay, C_OrderLine_ID, PriorityRule, QtyBatchSize, QtyBatchs, QtyDelivered, QtyEntered, QtyOrdered, DateConfirm, DateDelivered, DateFinish, DateFinishSchedule, DateOrdered, DatePromised, QtyReject, QtyReserved, QtyScrap, Yield, C_Campaign_ID, C_Project_ID, C_Activity_ID, User1_ID, User2_ID, AD_OrgTrx_ID, C_DocTypeTarget_ID, ScheduleType, IsApproved, DocAction, Posted, IsPrinted, OrderType, Logo_ID) AS SELECT o.ad_client_id AS AD_Client_ID, o.ad_org_id AS AD_Org_ID, o.isactive AS IsActive, o.created AS Created, o.createdby AS CreatedBy, o.updated AS Updated, o.updatedby AS UpdatedBy, dt.ad_language AS AD_Language, o.pp_order_id AS PP_Order_ID, o.documentno AS DocumentNo, o.docstatus AS DocStatus, o.c_doctype_id AS C_DocType_ID, oi.c_location_id AS Org_Location_ID, oi.taxid AS TaxID, o.m_warehouse_id AS M_Warehouse_ID, wh.c_location_id AS Warehouse_Location_ID, dt.printname AS DocumentType, dt.documentnote AS DocumentTypeNote, o.planner_id AS Planner_ID, u.name AS SalesRep_Name, o.datestart AS DateStart, o.datestartschedule AS DateStartSchedule, o.floatafter AS FloatAfter, o.floatbefored AS FloatBefored, o.line AS Line, o.lot AS Lot, o.serno AS SerNo, o.description AS Description, o.m_product_id AS M_Product_ID, o.m_attributesetinstance_id AS M_AttributeSetInstance_ID, o.c_uom_id AS C_UOM_ID, o.s_resource_id AS S_Resource_ID, o.pp_product_bom_id AS PP_Product_BOM_ID, o.ad_workflow_id AS AD_Workflow_ID, o.assay AS Assay, o.c_orderline_id AS C_OrderLine_ID, o.priorityrule AS PriorityRule, o.qtybatchsize AS QtyBatchSize, o.qtybatchs AS QtyBatchs, o.qtydelivered AS QtyDelivered, o.qtyentered AS QtyEntered, o.qtyordered AS QtyOrdered, o.dateconfirm AS DateConfirm, o.datedelivered AS DateDelivered, o.datefinish AS DateFinish, o.datefinishschedule AS DateFinishSchedule, o.dateordered AS DateOrdered, o.datepromised AS DatePromised, o.qtyreject AS QtyReject, o.qtyreserved AS QtyReserved, o.qtyscrap AS QtyScrap, o.yield AS Yield, o.c_campaign_id AS C_Campaign_ID, o.c_project_id AS C_Project_ID, o.c_activity_id AS C_Activity_ID, o.user1_id AS User1_ID, o.user2_id AS User2_ID, o.ad_orgtrx_id AS AD_OrgTrx_ID, o.c_doctypetarget_id AS C_DocTypeTarget_ID, o.scheduletype AS ScheduleType, o.isapproved AS IsApproved, o.docaction AS DocAction, o.posted AS Posted, o.isprinted AS IsPrinted, o.ordertype AS OrderType, COALESCE(oi.logo_id, ci.logo_id) AS Logo_ID FROM pp_order o JOIN c_doctype_trl dt ON o.c_doctype_id = dt.c_doctype_id JOIN m_warehouse wh ON o.m_warehouse_id = wh.m_warehouse_id JOIN ad_orginfo oi ON o.ad_org_id = oi.ad_org_id JOIN ad_clientinfo ci ON o.ad_client_id = ci.ad_client_id LEFT JOIN ad_user u ON o.planner_id = u.ad_user_id
;
-- Nov 28, 2021, 11:19:18 PM CET
CREATE OR REPLACE VIEW PP_Order_Node_vt(AD_Client_ID, AD_Org_ID, IsActive, Created, CreatedBy, Updated, UpdatedBy, AD_Language, Name, C_BPartner_ID, Cost, DateFinish, DateFinishSchedule, DateStart, DateStartSchedule, Description, DocAction, DocStatus, Duration, DurationReal, DurationRequiered, Help, IsMilestone, IsSubcontracting, MovingTime, OverlapUnits, PP_Order_ID, PP_Order_Workflow_ID, PP_Order_Node_ID, Priority, QtyDelivered, QtyRequiered, QtyScrap, QueuingTime, S_Resource_ID, SetupTime, SetupTimeReal, UnitsCycles, ValidFrom, ValidTo, Value, WaitingTime, WorkingTime, Yield) AS SELECT onode.ad_client_id AS AD_Client_ID, onode.ad_org_id AS AD_Org_ID, onode.isactive AS IsActive, onode.created AS Created, onode.createdby AS CreatedBy, onode.updated AS Updated, onode.updatedby AS UpdatedBy, ont.ad_language AS AD_Language, ont.name AS Name, onode.c_bpartner_id AS C_BPartner_ID, onode.cost AS Cost, onode.datefinish AS DateFinish, onode.datefinishschedule AS DateFinishSchedule, onode.datestart AS DateStart, onode.datestartschedule AS DateStartSchedule, ont.description AS Description, onode.docaction AS DocAction, onode.docstatus AS DocStatus, onode.duration AS Duration, onode.durationreal AS DurationReal, onode.durationrequiered AS DurationRequiered, ont.help AS Help, onode.ismilestone AS IsMilestone, onode.issubcontracting AS IsSubcontracting, onode.movingtime AS MovingTime, onode.overlapunits AS OverlapUnits, onode.pp_order_id AS PP_Order_ID, onode.pp_order_workflow_id AS PP_Order_Workflow_ID, onode.pp_order_node_id AS PP_Order_Node_ID, onode.priority AS Priority, onode.qtydelivered AS QtyDelivered, onode.qtyrequiered AS QtyRequiered, onode.qtyscrap AS QtyScrap, onode.queuingtime AS QueuingTime, onode.s_resource_id AS S_Resource_ID, onode.setuptime AS SetupTime, onode.setuptimereal AS SetupTimeReal, onode.unitscycles AS UnitsCycles, onode.validfrom AS ValidFrom, onode.validto AS ValidTo, onode.value AS Value, onode.waitingtime AS WaitingTime, onode.workingtime AS WorkingTime, onode.yield AS Yield FROM pp_order_node onode LEFT JOIN pp_order_node_trl ont ON ont.pp_order_node_id = onode.pp_order_node_id
;
-- Nov 28, 2021, 11:19:18 PM CET
CREATE OR REPLACE VIEW PP_Order_Workflow_Header_vt(AD_Client_ID, AD_Org_ID, IsActive, Created, CreatedBy, Updated, UpdatedBy, AD_Language, PP_Order_ID, DocStatus, C_DocType_ID, Org_Location_ID, TaxID, M_Warehouse_ID, Warehouse_Location_ID, DocumentType, DocumentTypeNote, Planner_ID, SalesRep_Name, DateStart, DateStartSchedule, FloatAfter, FloatBefored, Line, Lot, SerNo, C_UOM_ID, PP_Product_BOM_ID, Assay, C_OrderLine_ID, PriorityRule, QtyBatchSize, QtyBatchs, QtyDelivered, QtyEntered, QtyOrdered, DateConfirm, DateDelivered, DateFinish, DateFinishSchedule, DateOrdered, DatePromised, QtyReject, QtyReserved, QtyScrap, S_Resource_ID, C_Campaign_ID, C_Project_ID, C_Activity_ID, Name, Description, Help, Author, Cost, DocumentNo, Duration, DurationUnit, Version, ValidFrom, ValidTo, MovingTime, OverlapUnits, AD_Workflow_ID, PublishStatus, QueuingTime, SetupTime, UnitsCycles, WaitingTime, WorkflowType, WorkingTime, Yield, Logo_ID) AS SELECT o.ad_client_id AS AD_Client_ID, o.ad_org_id AS AD_Org_ID, o.isactive AS IsActive, o.created AS Created, o.createdby AS CreatedBy, o.updated AS Updated, o.updatedby AS UpdatedBy, owt.ad_language AS AD_Language, o.pp_order_id AS PP_Order_ID, o.docstatus AS DocStatus, o.c_doctype_id AS C_DocType_ID, oi.c_location_id AS Org_Location_ID, oi.taxid AS TaxID, o.m_warehouse_id AS M_Warehouse_ID, wh.c_location_id AS Warehouse_Location_ID, dt.printname AS DocumentType, dt.documentnote AS DocumentTypeNote, o.planner_id AS Planner_ID, u.name AS SalesRep_Name, o.datestart AS DateStart, o.datestartschedule AS DateStartSchedule, o.floatafter AS FloatAfter, o.floatbefored AS FloatBefored, o.line AS Line, o.lot AS Lot, o.serno AS SerNo, o.c_uom_id AS C_UOM_ID, o.pp_product_bom_id AS PP_Product_BOM_ID, o.assay AS Assay, o.c_orderline_id AS C_OrderLine_ID, o.priorityrule AS PriorityRule, o.qtybatchsize AS QtyBatchSize, o.qtybatchs AS QtyBatchs, o.qtydelivered AS QtyDelivered, o.qtyentered AS QtyEntered, o.qtyordered AS QtyOrdered, o.dateconfirm AS DateConfirm, o.datedelivered AS DateDelivered, o.datefinish AS DateFinish, o.datefinishschedule AS DateFinishSchedule, o.dateordered AS DateOrdered, o.datepromised AS DatePromised, o.qtyreject AS QtyReject, o.qtyreserved AS QtyReserved, o.qtyscrap AS QtyScrap, o.s_resource_id AS S_Resource_ID, o.c_campaign_id AS C_Campaign_ID, o.c_project_id AS C_Project_ID, o.c_activity_id AS C_Activity_ID, owt.name AS Name, owt.description AS Description, owt.help AS Help, ow.author AS Author, ow.cost AS Cost, ow.documentno AS DocumentNo, ow.duration AS Duration, ow.durationunit AS DurationUnit, ow.version AS Version, ow.validfrom AS ValidFrom, ow.validto AS ValidTo, ow.movingtime AS MovingTime, ow.overlapunits AS OverlapUnits, ow.ad_workflow_id AS AD_Workflow_ID, ow.publishstatus AS PublishStatus, ow.queuingtime AS QueuingTime, ow.setuptime AS SetupTime, ow.unitscycles AS UnitsCycles, ow.waitingtime AS WaitingTime, ow.workflowtype AS WorkflowType, ow.workingtime AS WorkingTime, ow.yield AS Yield, COALESCE(oi.logo_id, ci.logo_id) AS Logo_ID FROM pp_order o JOIN pp_order_workflow ow ON ow.pp_order_id = o.pp_order_id JOIN pp_order_workflow_trl owt ON owt.pp_order_workflow_id = ow.pp_order_workflow_id JOIN c_doctype dt ON o.c_doctype_id = dt.c_doctype_id JOIN m_warehouse wh ON o.m_warehouse_id = wh.m_warehouse_id JOIN ad_orginfo oi ON o.ad_org_id = oi.ad_org_id JOIN ad_clientinfo ci ON o.ad_client_id = ci.ad_client_id LEFT JOIN ad_user u ON o.planner_id = u.ad_user_id
;
-- Nov 28, 2021, 11:19:18 PM CET
CREATE OR REPLACE VIEW PP_Product_BOMLine_v(Feature, AD_Org_ID, Assay, BackflushGroup, C_UOM_ID, ComponentType, Created, CreatedBy, AD_Language, Description, Forecast, Help, IsActive, IsCritical, IsQtyPercentage, IssueMethod, LeadTimeOffset, Line, M_AttributeSetInstance_ID, M_ChangeNotice_ID, M_Product_ID, PP_Product_BOMLine_ID, PP_Product_BOM_ID, QtyBOM, QtyBatch, Scrap, Updated, UpdatedBy, ValidFrom, AD_Client_ID, ValidTo) AS SELECT bl.feature AS Feature, bl.ad_org_id AS AD_Org_ID, bl.assay AS Assay, bl.backflushgroup AS BackflushGroup, bl.c_uom_id AS C_UOM_ID, bl.componenttype AS ComponentType, bl.created AS Created, bl.createdby AS CreatedBy, CAST('en_US' AS CHARACTER VARYING(6)) AS AD_Language, blt.description AS Description, bl.forecast AS Forecast, blt.help AS Help, bl.isactive AS IsActive, bl.iscritical AS IsCritical, bl.isqtypercentage AS IsQtyPercentage, bl.issuemethod AS IssueMethod, bl.leadtimeoffset AS LeadTimeOffset, bl.line AS Line, bl.m_attributesetinstance_id AS M_AttributeSetInstance_ID, bl.m_changenotice_id AS M_ChangeNotice_ID, bl.m_product_id AS M_Product_ID, bl.pp_product_bomline_id AS PP_Product_BOMLine_ID, bl.pp_product_bom_id AS PP_Product_BOM_ID, bl.qtybom AS QtyBOM, bl.qtybatch AS QtyBatch, bl.scrap AS Scrap, bl.updated AS Updated, bl.updatedby AS UpdatedBy, bl.validfrom AS ValidFrom, bl.ad_client_id AS AD_Client_ID, bl.validto AS ValidTo FROM pp_product_bomline bl JOIN pp_product_bomline_trl blt ON blt.pp_product_bomline_id = bl.pp_product_bomline_id
;
-- Nov 28, 2021, 11:19:18 PM CET
CREATE OR REPLACE VIEW PP_Product_BOMLine_vt(Feature, AD_Org_ID, Assay, BackflushGroup, C_UOM_ID, ComponentType, Created, CreatedBy, AD_Language, Description, Forecast, Help, IsActive, IsCritical, IsQtyPercentage, IssueMethod, LeadTimeOffset, Line, M_AttributeSetInstance_ID, M_ChangeNotice_ID, M_Product_ID, PP_Product_BOMLine_ID, PP_Product_BOM_ID, QtyBOM, QtyBatch, Scrap, Updated, UpdatedBy, ValidFrom, AD_Client_ID, ValidTo) AS SELECT bl.feature AS Feature, bl.ad_org_id AS AD_Org_ID, bl.assay AS Assay, bl.backflushgroup AS BackflushGroup, bl.c_uom_id AS C_UOM_ID, bl.componenttype AS ComponentType, bl.created AS Created, bl.createdby AS CreatedBy, blt.ad_language AS AD_Language, blt.description AS Description, bl.forecast AS Forecast, blt.help AS Help, bl.isactive AS IsActive, bl.iscritical AS IsCritical, bl.isqtypercentage AS IsQtyPercentage, bl.issuemethod AS IssueMethod, bl.leadtimeoffset AS LeadTimeOffset, bl.line AS Line, bl.m_attributesetinstance_id AS M_AttributeSetInstance_ID, bl.m_changenotice_id AS M_ChangeNotice_ID, bl.m_product_id AS M_Product_ID, bl.pp_product_bomline_id AS PP_Product_BOMLine_ID, bl.pp_product_bom_id AS PP_Product_BOM_ID, bl.qtybom AS QtyBOM, bl.qtybatch AS QtyBatch, bl.scrap AS Scrap, bl.updated AS Updated, bl.updatedby AS UpdatedBy, bl.validfrom AS ValidFrom, bl.ad_client_id AS AD_Client_ID, bl.validto AS ValidTo FROM pp_product_bomline bl JOIN pp_product_bomline_trl blt ON blt.pp_product_bomline_id = bl.pp_product_bomline_id
;
-- Nov 28, 2021, 11:19:18 PM CET
CREATE OR REPLACE VIEW R_Request_v(R_Request_ID, AD_Client_ID, AD_Org_ID, IsActive, Created, CreatedBy, Updated, UpdatedBy, DocumentNo, R_RequestType_ID, R_Group_ID, R_Category_ID, R_Status_ID, R_Resolution_ID, R_RequestRelated_ID, Priority, PriorityUser, DueType, Summary, ConfidentialType, IsEscalated, IsSelfService, SalesRep_ID, AD_Role_ID, DateLastAction, DateLastAlert, LastResult, Processed, IsInvoiced, C_BPartner_ID, AD_User_ID, C_Campaign_ID, C_Order_ID, C_Invoice_ID, C_Payment_ID, M_Product_ID, C_Project_ID, A_Asset_ID, M_InOut_ID, M_RMA_ID, AD_Table_ID, Record_ID, RequestAmt, R_MailText_ID, Result, ConfidentialTypeEntry, R_StandardResponse_ID, NextAction, DateNextAction, StartTime, EndTime, QtySpent, QtyInvoiced, M_ProductSpent_ID, C_Activity_ID, StartDate, CloseDate, C_InvoiceRequest_ID, M_ChangeRequest_ID, TaskStatus, QtyPlan, DateCompletePlan, DateStartPlan, M_FixChangeNotice_ID) AS SELECT r_request.r_request_id AS R_Request_ID, r_request.ad_client_id AS AD_Client_ID, r_request.ad_org_id AS AD_Org_ID, r_request.isactive AS IsActive, r_request.created AS Created, r_request.createdby AS CreatedBy, r_request.updated AS Updated, r_request.updatedby AS UpdatedBy, r_request.documentno AS DocumentNo, r_request.r_requesttype_id AS R_RequestType_ID, r_request.r_group_id AS R_Group_ID, r_request.r_category_id AS R_Category_ID, r_request.r_status_id AS R_Status_ID, r_request.r_resolution_id AS R_Resolution_ID, r_request.r_requestrelated_id AS R_RequestRelated_ID, r_request.priority AS Priority, r_request.priorityuser AS PriorityUser, r_request.duetype AS DueType, r_request.summary AS Summary, r_request.confidentialtype AS ConfidentialType, r_request.isescalated AS IsEscalated, r_request.isselfservice AS IsSelfService, r_request.salesrep_id AS SalesRep_ID, r_request.ad_role_id AS AD_Role_ID, r_request.datelastaction AS DateLastAction, r_request.datelastalert AS DateLastAlert, r_request.lastresult AS LastResult, r_request.processed AS Processed, r_request.isinvoiced AS IsInvoiced, r_request.c_bpartner_id AS C_BPartner_ID, r_request.ad_user_id AS AD_User_ID, r_request.c_campaign_id AS C_Campaign_ID, r_request.c_order_id AS C_Order_ID, r_request.c_invoice_id AS C_Invoice_ID, r_request.c_payment_id AS C_Payment_ID, r_request.m_product_id AS M_Product_ID, r_request.c_project_id AS C_Project_ID, r_request.a_asset_id AS A_Asset_ID, r_request.m_inout_id AS M_InOut_ID, r_request.m_rma_id AS M_RMA_ID, r_request.ad_table_id AS AD_Table_ID, r_request.record_id AS Record_ID, r_request.requestamt AS RequestAmt, r_request.r_mailtext_id AS R_MailText_ID, r_request.result AS Result, r_request.confidentialtypeentry AS ConfidentialTypeEntry, r_request.r_standardresponse_id AS R_StandardResponse_ID, r_request.nextaction AS NextAction, r_request.datenextaction AS DateNextAction, r_request.starttime AS StartTime, r_request.endtime AS EndTime, r_request.qtyspent AS QtySpent, r_request.qtyinvoiced AS QtyInvoiced, r_request.m_productspent_id AS M_ProductSpent_ID, r_request.c_activity_id AS C_Activity_ID, r_request.startdate AS StartDate, r_request.closedate AS CloseDate, r_request.c_invoicerequest_id AS C_InvoiceRequest_ID, r_request.m_changerequest_id AS M_ChangeRequest_ID, r_request.taskstatus AS TaskStatus, r_request.qtyplan AS QtyPlan, r_request.datecompleteplan AS DateCompletePlan, r_request.datestartplan AS DateStartPlan, r_request.m_fixchangenotice_id AS M_FixChangeNotice_ID FROM r_request WHERE r_request.isactive = 'Y' AND r_request.processed = 'N' AND statement_timestamp() > r_request.datenextaction
;
-- Nov 28, 2021, 11:19:18 PM CET
CREATE OR REPLACE VIEW RV_OpenItemToDate(AD_Org_ID, AD_Client_ID, DocumentNo, C_Invoice_ID, C_Order_ID, C_BPartner_ID, IsSOTrx, DateInvoiced, DateAcct, NetDays, DueDate, DaysDue, DiscountDate, DiscountAmt, GrandTotal, C_Currency_ID, C_ConversionType_ID, C_PaymentTerm_ID, IsPayScheduleValid, C_InvoicePaySchedule_ID, InvoiceCollectionType, C_Campaign_ID, C_Project_ID, C_Activity_ID) AS SELECT i.ad_org_id AS AD_Org_ID, i.ad_client_id AS AD_Client_ID, i.documentno AS DocumentNo, i.c_invoice_id AS C_Invoice_ID, i.c_order_id AS C_Order_ID, i.c_bpartner_id AS C_BPartner_ID, i.issotrx AS IsSOTrx, i.dateinvoiced AS DateInvoiced, i.dateacct AS DateAcct, p.netdays AS NetDays, paymenttermduedate(i.c_paymentterm_id, i.dateinvoiced) AS DueDate, paymenttermduedays(i.c_paymentterm_id, i.dateinvoiced, statement_timestamp()) AS DaysDue, adddays(i.dateinvoiced, p.discountdays) AS DiscountDate, currencyround(i.grandtotal * p.discount / 100, i.c_currency_id, 'N') AS DiscountAmt, i.grandtotal AS GrandTotal, i.c_currency_id AS C_Currency_ID, i.c_conversiontype_id AS C_ConversionType_ID, i.c_paymentterm_id AS C_PaymentTerm_ID, i.ispayschedulevalid AS IsPayScheduleValid, NULL AS C_InvoicePaySchedule_ID, i.invoicecollectiontype AS InvoiceCollectionType, i.c_campaign_id AS C_Campaign_ID, i.c_project_id AS C_Project_ID, i.c_activity_id AS C_Activity_ID FROM rv_c_invoice i JOIN c_paymentterm p ON i.c_paymentterm_id = p.c_paymentterm_id WHERE i.ispayschedulevalid <> 'Y' AND (i.docstatus IN ('CO', 'CL')) UNION SELECT i.ad_org_id AS AD_Org_ID, i.ad_client_id AS AD_Client_ID, i.documentno AS DocumentNo, i.c_invoice_id AS C_Invoice_ID, i.c_order_id AS C_Order_ID, i.c_bpartner_id AS C_BPartner_ID, i.issotrx AS IsSOTrx, i.dateinvoiced AS DateInvoiced, i.dateacct AS DateAcct, daysbetween(ips.duedate, i.dateinvoiced) AS NetDays, ips.duedate AS DueDate, daysbetween(statement_timestamp(), ips.duedate) AS DaysDue, ips.discountdate AS DiscountDate, ips.discountamt AS DiscountAmt, ips.dueamt AS GrandTotal, i.c_currency_id AS C_Currency_ID, i.c_conversiontype_id AS C_ConversionType_ID, i.c_paymentterm_id AS C_PaymentTerm_ID, i.ispayschedulevalid AS IsPayScheduleValid, ips.c_invoicepayschedule_id AS C_InvoicePaySchedule_ID, i.invoicecollectiontype AS InvoiceCollectionType, i.c_campaign_id AS C_Campaign_ID, i.c_project_id AS C_Project_ID, i.c_activity_id AS C_Activity_ID FROM rv_c_invoice i JOIN c_invoicepayschedule ips ON i.c_invoice_id = ips.c_invoice_id WHERE i.ispayschedulevalid = 'Y' AND (i.docstatus IN ('CO', 'CL')) AND ips.isvalid = 'Y'
;
-- Nov 28, 2021, 11:19:18 PM CET
CREATE OR REPLACE VIEW RV_PP_Order(AD_Client_ID, AD_Org_ID, IsActive, Created, CreatedBy, Updated, UpdatedBy, PP_Order_ID, DocumentNo, DocStatus, M_Warehouse_ID, M_Product_ID, QtyEntered, QtyReject, QtyScrap, QtyBatchs, QtyBatchSize, DateOrdered, DatePromised, DateStart, DateStartSchedule, DateFinish, DateFinishSchedule, DateConfirm, DateDelivered, Lot, PP_Product_BOM_ID, AD_Workflow_ID, Weight, C_DocTypeTarget_ID, M_AttributeSetInstance_ID, Planner_ID, PriorityRule, AD_OrgTrx_ID, User1_ID, User2_ID, C_DocType_ID, Line, Description, S_Resource_ID, FloatBefored, FloatAfter, C_UOM_ID, QtyOrdered, QtyDelivered, Yield, C_Project_ID, C_Campaign_ID, C_Activity_ID, IsApproved, IsPrinted, IsSelected, Processed, Assay, IsQtyPercentage, OrderType, IsSOTrx, ScheduleType, SerNo) AS SELECT o.ad_client_id AS AD_Client_ID, o.ad_org_id AS AD_Org_ID, o.isactive AS IsActive, o.created AS Created, o.createdby AS CreatedBy, o.updated AS Updated, o.updatedby AS UpdatedBy, o.pp_order_id AS PP_Order_ID, o.documentno AS DocumentNo, o.docstatus AS DocStatus, o.m_warehouse_id AS M_Warehouse_ID, o.m_product_id AS M_Product_ID, o.qtyentered AS QtyEntered, o.qtyreject AS QtyReject, o.qtyscrap AS QtyScrap, o.qtybatchs AS QtyBatchs, o.qtybatchsize AS QtyBatchSize, o.dateordered AS DateOrdered, o.datepromised AS DatePromised, o.datestart AS DateStart, o.datestartschedule AS DateStartSchedule, o.datefinish AS DateFinish, o.datefinishschedule AS DateFinishSchedule, o.dateconfirm AS DateConfirm, o.datedelivered AS DateDelivered, o.lot AS Lot, o.pp_product_bom_id AS PP_Product_BOM_ID, o.ad_workflow_id AS AD_Workflow_ID, ( SELECT p.weight FROM m_product p WHERE p.m_product_id = o.m_product_id) AS Weight, o.c_doctypetarget_id AS C_DocTypeTarget_ID, o.m_attributesetinstance_id AS M_AttributeSetInstance_ID, o.planner_id AS Planner_ID, o.priorityrule AS PriorityRule, o.ad_orgtrx_id AS AD_OrgTrx_ID, o.user1_id AS User1_ID, o.user2_id AS User2_ID, o.c_doctype_id AS C_DocType_ID, o.line AS Line, o.description AS Description, o.s_resource_id AS S_Resource_ID, o.floatbefored AS FloatBefored, o.floatafter AS FloatAfter, o.c_uom_id AS C_UOM_ID, o.qtyordered AS QtyOrdered, o.qtydelivered AS QtyDelivered, o.yield AS Yield, o.c_project_id AS C_Project_ID, o.c_campaign_id AS C_Campaign_ID, o.c_activity_id AS C_Activity_ID, o.isapproved AS IsApproved, o.isprinted AS IsPrinted, o.isselected AS IsSelected, o.processed AS Processed, o.assay AS Assay, o.isqtypercentage AS IsQtyPercentage, o.ordertype AS OrderType, o.issotrx AS IsSOTrx, o.scheduletype AS ScheduleType, o.serno AS SerNo FROM pp_order o
;
-- Nov 28, 2021, 11:19:18 PM CET
CREATE OR REPLACE VIEW RV_PP_Order_Receipt_Issue(PP_Order_BOMLine_ID, IsCritical, Value, M_Product_ID, ProductName, M_AttributeSetInstance_ID, instancename, C_UOM_ID, UOMName, QtyRequiered, qtyreserved_order, QtyOnHand, qtyreserved_storage, QtyAvailable, M_Locator_ID, M_Warehouse_ID, WarehouseName, QtyBOM, IsQtyPercentage, QtyBatch, ComponentType, qtyopen, PP_Order_ID) AS SELECT obl.pp_order_bomline_id AS PP_Order_BOMLine_ID, obl.iscritical AS IsCritical, p.value AS Value, obl.m_product_id AS M_Product_ID, mos.name AS ProductName, mos.m_attributesetinstance_id AS M_AttributeSetInstance_ID, asi.description AS instancename, mos.c_uom_id AS C_UOM_ID, u.name AS UOMName, obl.qtyrequiered AS QtyRequiered, obl.qtyreserved AS qtyreserved_order, mos.qtyonhand AS QtyOnHand, mos.qtyreserved AS qtyreserved_storage, mos.qtyavailable AS QtyAvailable, mos.m_locator_id AS M_Locator_ID, mos.m_warehouse_id AS M_Warehouse_ID, w.name AS WarehouseName, mos.qtybom AS QtyBOM, mos.isqtypercentage AS IsQtyPercentage, mos.qtybatch AS QtyBatch, obl.componenttype AS ComponentType, mos.qtyrequiered - obl.qtydelivered AS qtyopen, obl.pp_order_id AS PP_Order_ID FROM rv_pp_order_storage mos JOIN pp_order_bomline obl ON mos.pp_order_bomline_id = obl.pp_order_bomline_id JOIN m_attributesetinstance asi ON mos.m_attributesetinstance_id = asi.m_attributesetinstance_id JOIN c_uom u ON mos.c_uom_id = u.c_uom_id JOIN m_product p ON mos.m_product_id = p.m_product_id JOIN m_warehouse w ON mos.m_warehouse_id = w.m_warehouse_id
;
-- Nov 28, 2021, 11:19:18 PM CET
CREATE OR REPLACE VIEW RV_RequestUpdates_v(AD_Client_ID, AD_Org_ID, IsActive, Created, CreatedBy, Updated, UpdatedBy, R_Request_ID, AD_User_ID) AS SELECT min(rv_requestupdates.ad_client_id) AS AD_Client_ID, min(rv_requestupdates.ad_org_id) AS AD_Org_ID, CAST('Y' AS CHAR(1)) AS IsActive, statement_timestamp() AS Created, 0 AS CreatedBy, statement_timestamp() AS Updated, 0 AS UpdatedBy, rv_requestupdates.r_request_id AS R_Request_ID, rv_requestupdates.ad_user_id AS AD_User_ID FROM rv_requestupdates WHERE rv_requestupdates.isactive = 'Y' GROUP BY rv_requestupdates.r_request_id, rv_requestupdates.ad_user_id
;
-- Nov 28, 2021, 11:19:18 PM CET
CREATE OR REPLACE VIEW X_PackageLineWeight(AD_Client_ID, M_Package_ID, Qty, M_InOutLine_ID, M_InOut_ID, M_Product_ID, Weight, lineweight, M_PackageMPS_ID) AS SELECT pl.ad_client_id AS AD_Client_ID, pl.m_package_id AS M_Package_ID, pl.qty AS Qty, pl.m_inoutline_id AS M_InOutLine_ID, iol.m_inout_id AS M_InOut_ID, iol.m_product_id AS M_Product_ID, p.weight AS Weight, pl.qty * p.weight AS lineweight, pl.m_packagemps_id AS M_PackageMPS_ID FROM m_packageline pl JOIN m_inoutline iol ON pl.m_inoutline_id = iol.m_inoutline_id JOIN m_product p ON iol.m_product_id = p.m_product_id
;
-- Nov 28, 2021, 11:19:18 PM CET
CREATE OR REPLACE VIEW RV_Fact_Adaxa(AD_Client_ID, AD_Org_ID, ClientName, DateAcct, BSDate, BSMth, FYear, FYMth, Table_Name, Record_ID, BudName, TaxName, Act_Bud, Currency, AmtSce, AmtAcct, pl_act, bs_act, pl_bud, UOMName, Qty, ProjectName, Description, OrgName, AC_Code, AC_Name, Account_Name, BSTypeName, PLTypeName, AC_Group, BSGroup, PLGroup, PLBS, Na_Eq, BPCode, BPName, BPartnerCodeAndName, BPGroupName, RepName, ProdCode, ProdName, Product, ProdCategory) AS SELECT f.ad_client_id AS AD_Client_ID, f.ad_org_id AS AD_Org_ID, ( SELECT cli.name FROM ad_client cli WHERE cli.ad_client_id = f.ad_client_id) AS ClientName, f.dateacct AS DateAcct, CASE WHEN f.dateacct < (( SELECT clinfo.fy_startdate FROM ad_clientinfo clinfo WHERE clinfo.ad_client_id = f.ad_client_id)) THEN ( SELECT clinfo.fy_startdate - 1 FROM ad_clientinfo clinfo WHERE clinfo.ad_client_id = f.ad_client_id) ELSE f.dateacct END AS BSDate, CASE WHEN f.dateacct < (( SELECT clinfo.fy_startdate FROM ad_clientinfo clinfo WHERE clinfo.ad_client_id = f.ad_client_id)) THEN ( SELECT to_char(clinfo.fy_startdate - 1, 'YYYY-MM') AS to_char FROM ad_clientinfo clinfo WHERE clinfo.ad_client_id = f.ad_client_id) ELSE to_char(f.dateacct, 'YYYY-MM') END AS BSMth, to_char(f.dateacct + 184, '"FY"YYYY') AS FYear, to_char(f.dateacct, 'YYYY-MM') AS FYMth, ( SELECT t.name FROM ad_table t WHERE t.ad_table_id = f.ad_table_id) AS Table_Name, f.record_id AS Record_ID, ( SELECT gl.name FROM gl_budget gl WHERE gl.gl_budget_id = f.gl_budget_id) AS BudName, ( SELECT tax.name FROM c_tax tax WHERE tax.c_tax_id = f.c_tax_id) AS TaxName, CASE f.postingtype WHEN 'A' THEN 'Actual' WHEN 'B' THEN 'Budget' WHEN 'E' THEN 'Encumbrance' WHEN 'S' THEN 'Statistic' ELSE 'Other' END AS Act_Bud, ( SELECT c.iso_code FROM c_currency c WHERE c.c_currency_id = f.c_currency_id) AS Currency, f.amtsourcedr - f.amtsourcecr AS AmtSce, f.amtacctdr - f.amtacctcr AS AmtAcct, CASE WHEN f.postingtype = 'B' THEN 0 ELSE f.amtacctcr - f.amtacctdr END AS pl_act, CASE WHEN f.postingtype = 'B' THEN 0 WHEN ev.accounttype = 'A' THEN f.amtacctdr - f.amtacctcr WHEN ev.accounttype = 'L' THEN f.amtacctdr - f.amtacctcr WHEN ev.accounttype = 'O' THEN f.amtacctcr - f.amtacctdr WHEN ev.accounttype = 'E' THEN f.amtacctcr - f.amtacctdr WHEN ev.accounttype = 'R' THEN f.amtacctcr - f.amtacctdr ELSE 0 END AS bs_act, CASE WHEN f.postingtype = 'A' THEN 0 WHEN ev.accounttype = 'E' THEN f.amtacctcr - f.amtacctdr WHEN ev.accounttype = 'R' THEN f.amtacctcr - f.amtacctdr ELSE 0 END AS pl_bud, ( SELECT um.uomsymbol FROM c_uom um WHERE um.c_uom_id = f.c_uom_id) AS UOMName, f.qty AS Qty, ( SELECT prj.name FROM c_project prj WHERE prj.c_project_id = f.c_project_id) AS ProjectName, f.description AS Description, o.name AS OrgName, ev.value AS AC_Code, ev.name AS AC_Name, (ev.value || '-') || ev.name AS Account_Name, CASE ev.accounttype WHEN 'A' THEN '1 Asset' WHEN 'E' THEN '3 Equity' WHEN 'L' THEN '2 Liability' WHEN 'M' THEN '9 Memo' WHEN 'O' THEN '3 Equity' WHEN 'R' THEN '3 Equity' ELSE '9. Unknown' END AS BSTypeName, CASE ev.accounttype WHEN 'A' THEN '9 BSheet' WHEN 'E' THEN '6 Expense' WHEN 'L' THEN '9 BSheet' WHEN 'M' THEN '9 Memo' WHEN 'O' THEN '9 BSheet' WHEN 'R' THEN '4 Revenue' ELSE '9. Unknown' END AS PLTypeName, ( SELECT (ss.value || '-') || ss.name FROM c_elementvalue ss WHERE ss.value = substr(ev.value, 1, 1) AND ss.issummary = 'Y' AND ss.ad_client_id = f.ad_client_id) AS AC_Group, CASE ev.accounttype WHEN 'A' THEN ( SELECT (ss.value || '-') || ss.name FROM c_elementvalue ss WHERE ss.value = substr(ev.value, 1, 3) AND ss.issummary = 'Y' AND ss.ad_client_id = f.ad_client_id) WHEN 'E' THEN '330-Current P and L Accounts Balance' WHEN 'L' THEN ( SELECT (ss.value || '-') || ss.name FROM c_elementvalue ss WHERE ss.value = substr(ev.value, 1, 3) AND ss.issummary = 'Y' AND ss.ad_client_id = f.ad_client_id) WHEN 'O' THEN ( SELECT (ss.value || '-') || ss.name FROM c_elementvalue ss WHERE ss.value = substr(ev.value, 1, 3) AND ss.issummary = 'Y' AND ss.ad_client_id = f.ad_client_id) WHEN 'R' THEN '330-Current P and L Accounts Balance' ELSE 'Unknown Account
;
SELECT register_migration_script('202111282319_IDEMPIERE-5059.sql') FROM dual
;