Exemplo n.º 1
0
        }       //	issueExpense

        /**
         *	Issue Project Line
         *	@return Message (clear text)
         */
        private String IssueProjectLine()
        {
            MProjectLine pl = new MProjectLine(GetCtx(), m_C_ProjectLine_ID, Get_TrxName());

            if (pl.GetM_Product_ID() == 0)
            {
                throw new ArgumentException("Projet Line has no Product");
            }
            if (pl.GetC_ProjectIssue_ID() != 0)
            {
                throw new ArgumentException("Projet Line already been issued");
            }
            if (m_M_Locator_ID == 0)
            {
                throw new ArgumentException("No Locator");
            }
            //	Set to Qty 1
            if (Env.Signum(pl.GetPlannedQty()) == 0)
            {
                pl.SetPlannedQty(Env.ONE);
            }
            //
            MProjectIssue pi = new MProjectIssue(m_project);

            pi.SetMandatory(m_M_Locator_ID, pl.GetM_Product_ID(), pl.GetPlannedQty());
            if (m_MovementDate != null)         //	default today
            {
                pi.SetMovementDate(m_MovementDate);
            }
            if (m_Description != null && m_Description.Length > 0)
            {
                pi.SetDescription(m_Description);
            }
            else if (pl.GetDescription() != null)
            {
                pi.SetDescription(pl.GetDescription());
            }
            pi.Process();

            //	Update Line
            pl.SetMProjectIssue(pi);
            pl.Save();
            AddLog(pi.GetLine(), pi.GetMovementDate(), pi.GetMovementQty(), null);
            return("@Created@ 1");
        }       //	issueProjectLine
Exemplo n.º 2
0
        /// <summary>
        /// Load Document Details
        /// </summary>
        /// <returns>error message or null</returns>
        public override String LoadDocumentDetails()
        {
            SetC_Currency_ID(NO_CURRENCY);
            _issue = (MProjectIssue)GetPO();
            SetDateDoc(_issue.GetMovementDate());
            SetDateAcct(_issue.GetMovementDate());

            //	Pseudo Line
            _line = new DocLine(_issue, this);
            _line.SetQty(_issue.GetMovementQty(), true);    //  sets Trx and Storage Qty

            //	Pseudo Line Check
            if (_line.GetM_Product_ID() == 0)
            {
                log.Warning(_line.ToString() + " - No Product");
            }
            log.Fine(_line.ToString());
            return(null);
        }
Exemplo n.º 3
0
        }       //	issueProjectLine

        /**
         *	Issue from Inventory
         *	@return Message (clear text)
         */
        private String IssueInventory()
        {
            if (m_M_Locator_ID == 0)
            {
                throw new ArgumentException("No Locator");
            }
            if (m_M_Product_ID == 0)
            {
                throw new ArgumentException("No Product");
            }
            //	Set to Qty 1
            if (m_MovementQty == null || (m_MovementQty) == 0)
            {
                m_MovementQty = Env.ONE;
            }
            //
            MProjectIssue pi = new MProjectIssue(m_project);

            pi.SetMandatory(m_M_Locator_ID, m_M_Product_ID, m_MovementQty.Value);
            if (m_MovementDate != null)         //	default today
            {
                pi.SetMovementDate(m_MovementDate);
            }
            if (m_Description != null && m_Description.Length > 0)
            {
                pi.SetDescription(m_Description);
            }
            pi.Process();

            //	Create Project Line
            MProjectLine pl = new MProjectLine(m_project);

            pl.SetMProjectIssue(pi);
            pl.Save();
            AddLog(pi.GetLine(), pi.GetMovementDate(), pi.GetMovementQty(), null);
            return("@Created@ 1");
        }       //	issueInventory
Exemplo n.º 4
0
        }       //	issueReceipt

        /**
         *	Issue Expense Report
         *	@return Message (clear text)
         */
        private String IssueExpense()
        {
            //	Get Expense Report
            MTimeExpense expense = new MTimeExpense(GetCtx(), m_S_TimeExpense_ID, Get_TrxName());

            if (!expense.IsProcessed())
            {
                throw new ArgumentException("Time+Expense not processed - " + expense);
            }

            //	for all expense lines
            MTimeExpenseLine[] expenseLines = expense.GetLines(false);
            int counter = 0;

            for (int i = 0; i < expenseLines.Length; i++)
            {
                //	Need to have a Product
                if (expenseLines[i].GetM_Product_ID() == 0)
                {
                    continue;
                }
                //	Need to have Quantity
                if (Env.Signum(expenseLines[i].GetQty()) == 0)
                {
                    continue;
                }
                //	Need to the same project
                if (expenseLines[i].GetC_Project_ID() != m_project.GetC_Project_ID())
                {
                    continue;
                }
                //	not issued yet
                if (ProjectIssueHasExpense(expenseLines[i].GetS_TimeExpenseLine_ID()))
                {
                    continue;
                }

                //	Find Location
                int M_Locator_ID = 0;
                //	MProduct product = new MProduct (getCtx(), expenseLines[i].getM_Product_ID());
                //	if (product.isStocked())
                M_Locator_ID = MStorage.GetM_Locator_ID(expense.GetM_Warehouse_ID(),
                                                        expenseLines[i].GetM_Product_ID(), 0, //	no ASI
                                                        expenseLines[i].GetQty(), null);
                if (M_Locator_ID == 0)                                                        //	Service/Expense - get default (and fallback)
                {
                    M_Locator_ID = expense.GetM_Locator_ID();
                }

                //	Create Issue
                MProjectIssue pi = new MProjectIssue(m_project);
                pi.SetMandatory(M_Locator_ID, expenseLines[i].GetM_Product_ID(), expenseLines[i].GetQty());
                if (m_MovementDate != null)             //	default today
                {
                    pi.SetMovementDate(m_MovementDate);
                }
                if (m_Description != null && m_Description.Length > 0)
                {
                    pi.SetDescription(m_Description);
                }
                else if (expenseLines[i].GetDescription() != null)
                {
                    pi.SetDescription(expenseLines[i].GetDescription());
                }
                pi.SetS_TimeExpenseLine_ID(expenseLines[i].GetS_TimeExpenseLine_ID());
                pi.Process();
                //	Find/Create Project Line
                MProjectLine pl = new MProjectLine(m_project);
                pl.SetMProjectIssue(pi);                //	setIssue
                pl.Save();
                AddLog(pi.GetLine(), pi.GetMovementDate(), pi.GetMovementQty(), null);
                counter++;
            }   //	allExpenseLines

            return("@Created@ " + counter);
        }       //	issueExpense
Exemplo n.º 5
0
        /**
         *	Issue Receipt
         *	@return Message (clear text)
         */
        private String IssueReceipt()
        {
            MInOut inOut = new MInOut(GetCtx(), m_M_InOut_ID, null);

            if (inOut.IsSOTrx() || !inOut.IsProcessed() ||
                !(MInOut.DOCSTATUS_Completed.Equals(inOut.GetDocStatus()) || MInOut.DOCSTATUS_Closed.Equals(inOut.GetDocStatus())))
            {
                throw new ArgumentException("Receipt not valid - " + inOut);
            }
            log.Info(inOut.ToString());
            //	Set Project of Receipt
            if (inOut.GetC_Project_ID() == 0)
            {
                inOut.SetC_Project_ID(m_project.GetC_Project_ID());
                inOut.Save();
            }
            else if (inOut.GetC_Project_ID() != m_project.GetC_Project_ID())
            {
                throw new ArgumentException("Receipt for other Project (" + inOut.GetC_Project_ID() + ")");
            }

            MInOutLine[] inOutLines = inOut.GetLines(false);
            int          counter    = 0;

            for (int i = 0; i < inOutLines.Length; i++)
            {
                //	Need to have a Product
                if (inOutLines[i].GetM_Product_ID() == 0)
                {
                    continue;
                }
                //	Need to have Quantity
                if (Env.Signum(inOutLines[i].GetMovementQty()) == 0)
                {
                    continue;
                }
                //	not issued yet
                if (ProjectIssueHasReceipt(inOutLines[i].GetM_InOutLine_ID()))
                {
                    continue;
                }
                //	Create Issue
                MProjectIssue pi = new MProjectIssue(m_project);
                pi.SetMandatory(inOutLines[i].GetM_Locator_ID(), inOutLines[i].GetM_Product_ID(), inOutLines[i].GetMovementQty());
                if (m_MovementDate != null)             //	default today
                {
                    pi.SetMovementDate(m_MovementDate);
                }
                if (m_Description != null && m_Description.Length > 0)
                {
                    pi.SetDescription(m_Description);
                }
                else if (inOutLines[i].GetDescription() != null)
                {
                    pi.SetDescription(inOutLines[i].GetDescription());
                }
                else if (inOut.GetDescription() != null)
                {
                    pi.SetDescription(inOut.GetDescription());
                }
                pi.SetM_InOutLine_ID(inOutLines[i].GetM_InOutLine_ID());
                pi.Process();

                //	Find/Create Project Line
                MProjectLine   pl  = null;
                MProjectLine[] pls = m_project.GetLines();
                for (int ii = 0; ii < pls.Length; ii++)
                {
                    //	The Order we generated is the same as the Order of the receipt
                    if (pls[ii].GetC_OrderPO_ID() == inOut.GetC_Order_ID() &&
                        pls[ii].GetM_Product_ID() == inOutLines[i].GetM_Product_ID() &&
                        pls[ii].GetC_ProjectIssue_ID() == 0)            //	not issued
                    {
                        pl = pls[ii];
                        break;
                    }
                }
                if (pl == null)
                {
                    pl = new MProjectLine(m_project);
                }
                pl.SetMProjectIssue(pi);                //	setIssue
                pl.Save();
                AddLog(pi.GetLine(), pi.GetMovementDate(), pi.GetMovementQty(), null);
                counter++;
            }   //	all InOutLines

            return("@Created@ " + counter);
        }       //	issueReceipt