예제 #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
예제 #2
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
예제 #3
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
예제 #4
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