Exemplo n.º 1
0
        /// <summary>
        /// Set Document Info
        /// </summary>
        /// <param name="doc">document</param>
        /// <param name="docLine">doc line</param>
        public void SetDocumentInfo(Doc doc, DocLine docLine)
        {
            _doc     = doc;
            _docLine = docLine;
            //	reset
            SetAD_Org_ID(0);
            SetC_SalesRegion_ID(0);
            //	Client
            if (GetAD_Client_ID() == 0)
            {
                SetAD_Client_ID(_doc.GetAD_Client_ID());
            }
            //	Date Trx
            SetDateTrx(_doc.GetDateDoc());
            if (_docLine != null && _docLine.GetDateDoc() != null)
            {
                SetDateTrx(_docLine.GetDateDoc());
            }
            //	Date Acct
            SetDateAcct(_doc.GetDateAcct());
            if (_docLine != null && _docLine.GetDateAcct() != null)
            {
                SetDateAcct(_docLine.GetDateAcct());
            }
            //	Period, Tax
            if (_docLine != null && _docLine.GetC_Period_ID() != 0)
            {
                SetC_Period_ID(_docLine.GetC_Period_ID());
            }
            else
            {
                SetC_Period_ID(_doc.GetC_Period_ID());
            }
            if (_docLine != null)
            {
                SetC_Tax_ID(_docLine.GetC_Tax_ID());
            }
            //	Description
            StringBuilder description = new StringBuilder(_doc.GetDocumentNo());

            if (_docLine != null)
            {
                description.Append(" #").Append(_docLine.GetLine());
                if (_docLine.GetDescription() != null)
                {
                    description.Append(" (").Append(_docLine.GetDescription()).Append(")");
                }
                else if (_doc.GetDescription() != null && _doc.GetDescription().Length > 0)
                {
                    description.Append(" (").Append(_doc.GetDescription()).Append(")");
                }
            }
            else if (_doc.GetDescription() != null && _doc.GetDescription().Length > 0)
            {
                description.Append(" (").Append(_doc.GetDescription()).Append(")");
            }
            SetDescription(description.ToString());
            //	Journal Info
            SetGL_Budget_ID(_doc.GetGL_Budget_ID());
            SetGL_Category_ID(_doc.GetGL_Category_ID());

            //	Product
            if (_docLine != null)
            {
                SetM_Product_ID(_docLine.GetM_Product_ID());
            }
            if (GetM_Product_ID() == 0)
            {
                SetM_Product_ID(_doc.GetM_Product_ID());
            }
            //	UOM
            if (_docLine != null)
            {
                SetC_UOM_ID(_docLine.GetC_UOM_ID());
            }
            //	Qty
            if (Get_Value("Qty") == null) // not previously set
            {
                SetQty(_doc.GetQty());    //	neg = outgoing
                if (_docLine != null)
                {
                    SetQty(_docLine.GetQty());
                }
            }

            //	Loc From (maybe set earlier)
            if (GetC_LocFrom_ID() == 0 && _docLine != null)
            {
                SetC_LocFrom_ID(_docLine.GetC_LocFrom_ID());
            }
            if (GetC_LocFrom_ID() == 0)
            {
                SetC_LocFrom_ID(_doc.GetC_LocFrom_ID());
            }
            //	Loc To (maybe set earlier)
            if (GetC_LocTo_ID() == 0 && _docLine != null)
            {
                SetC_LocTo_ID(_docLine.GetC_LocTo_ID());
            }
            if (GetC_LocTo_ID() == 0)
            {
                SetC_LocTo_ID(_doc.GetC_LocTo_ID());
            }
            //	BPartner
            if (_docLine != null)
            {
                SetC_BPartner_ID(_docLine.GetC_BPartner_ID());
            }
            if (GetC_BPartner_ID() == 0)
            {
                SetC_BPartner_ID(_doc.GetC_BPartner_ID());
            }
            //	Sales Region from BPLocation/Sales Rep
            //	Trx Org
            if (_docLine != null)
            {
                SetAD_OrgTrx_ID(_docLine.GetAD_OrgTrx_ID());
            }
            if (GetAD_OrgTrx_ID() == 0)
            {
                SetAD_OrgTrx_ID(_doc.GetAD_OrgTrx_ID());
            }
            //	Project
            if (_docLine != null)
            {
                SetC_Project_ID(_docLine.GetC_Project_ID());
            }
            if (GetC_Project_ID() == 0)
            {
                SetC_Project_ID(_doc.GetC_Project_ID());
            }
            //	Campaign
            if (_docLine != null)
            {
                SetC_Campaign_ID(_docLine.GetC_Campaign_ID());
            }
            if (GetC_Campaign_ID() == 0)
            {
                SetC_Campaign_ID(_doc.GetC_Campaign_ID());
            }
            //	Activity
            if (_docLine != null)
            {
                SetC_Activity_ID(_docLine.GetC_Activity_ID());
            }
            if (GetC_Activity_ID() == 0)
            {
                SetC_Activity_ID(_doc.GetC_Activity_ID());
            }
            //	User List 1
            if (_docLine != null)
            {
                SetUser1_ID(_docLine.GetUser1_ID());
            }
            if (GetUser1_ID() == 0)
            {
                SetUser1_ID(_doc.GetUser1_ID());
            }
            //	User List 2
            if (_docLine != null)
            {
                SetUser2_ID(_docLine.GetUser2_ID());
            }
            if (GetUser2_ID() == 0)
            {
                SetUser2_ID(_doc.GetUser2_ID());
            }
            //	References in setAccount
        }