예제 #1
0
        }       //	prepare

        /// <summary>
        /// Perrform Process.
        /// </summary>
        /// <returns>Message (translated text)</returns>
        protected override String DoIt()
        {
            MProject project = new MProject(GetCtx(), m_C_Project_ID, Get_TrxName());

            log.Info("doIt - " + project);

            MProjectLine[] projectLines = project.GetLines();
            if (MProject.PROJECTCATEGORY_WorkOrderJob.Equals(project.GetProjectCategory()) ||
                MProject.PROJECTCATEGORY_AssetProject.Equals(project.GetProjectCategory()))
            {
                /** @todo Check if we should close it */
            }

            //	Close lines
            for (int line = 0; line < projectLines.Length; line++)
            {
                projectLines[line].SetProcessed(true);
                projectLines[line].Save();
            }

            project.SetProcessed(true);
            project.Save();

            return("");
        } //	doIt
예제 #2
0
        /**
         *  Perrform process.
         *  @return Message (clear text)
         *  @throws Exception if not successful
         */
        protected override string DoIt()
        {
            //	Check Parameter
            m_project = new MProject(GetCtx(), m_C_Project_ID, Get_TrxName());
            if (!(MProject.PROJECTCATEGORY_WorkOrderJob.Equals(m_project.GetProjectCategory()) ||
                  MProject.PROJECTCATEGORY_AssetProject.Equals(m_project.GetProjectCategory())))
            {
                throw new ArgumentException("Project not Work Order or Asset =" + m_project.GetProjectCategory());
            }
            log.Info(m_project.ToString());

            //
            if (m_M_InOut_ID != 0)
            {
                return(IssueReceipt());
            }
            if (m_S_TimeExpense_ID != 0)
            {
                return(IssueExpense());
            }
            if (m_M_Locator_ID == 0)
            {
                throw new ArgumentException("Locator missing");
            }
            if (m_C_ProjectLine_ID != 0)
            {
                return(IssueProjectLine());
            }
            return(IssueInventory());
            //return "";
        }
예제 #3
0
        /// <summary>
        /// Create Facts (the accounting logic) for
        ///  PJI
        ///  <pre>
        ///  Issue
        ///      ProjectWIP      DR
        ///      Inventory               CR
        ///  </pre>
        ///  Project Account is either Asset or WIP depending on Project Type
        /// </summary>
        /// <param name="?"></param>
        /// <returns>fact</returns>
        public override List <Fact> CreateFacts(MAcctSchema as1)
        {
            //  create Fact Header
            Fact fact = new Fact(this, as1, Fact.POST_Actual);

            SetC_Currency_ID(as1.GetC_Currency_ID());

            MProject project         = new MProject(GetCtx(), _issue.GetC_Project_ID(), null);
            String   ProjectCategory = project.GetProjectCategory();
            MProduct product         = MProduct.Get(GetCtx(), _issue.GetM_Product_ID());

            //  Line pointers
            FactLine dr = null;
            FactLine cr = null;

            //  Issue Cost
            Decimal?cost = null;

            if (_issue.GetM_InOutLine_ID() != 0)
            {
                cost = GetPOCost(as1);
            }
            else if (_issue.GetS_TimeExpenseLine_ID() != 0)
            {
                cost = GetLaborCost(as1);
            }
            if (cost == null)   //	standard Product Costs
            {
                cost = _line.GetProductCosts(as1, GetAD_Org_ID(), false);
            }

            //  Project         DR
            int acctType = ACCTTYPE_ProjectWIP;

            if (MProject.PROJECTCATEGORY_AssetProject.Equals(ProjectCategory))
            {
                acctType = ACCTTYPE_ProjectAsset;
            }
            dr = fact.CreateLine(_line,
                                 GetAccount(acctType, as1), as1.GetC_Currency_ID(), cost, null);
            dr.SetQty((Decimal?)Decimal.Negate(Utility.Util.GetValueOfDecimal(_line.GetQty())));

            //  Inventory               CR
            acctType = ProductCost.ACCTTYPE_P_Asset;
            if (product.IsService())
            {
                acctType = ProductCost.ACCTTYPE_P_Expense;
            }
            cr = fact.CreateLine(_line,
                                 _line.GetAccount(acctType, as1),
                                 as1.GetC_Currency_ID(), null, cost);
            cr.SetM_Locator_ID(_line.GetM_Locator_ID());
            cr.SetLocationFromLocator(_line.GetM_Locator_ID(), true);   // from Loc
            //
            List <Fact> facts = new List <Fact>();

            facts.Add(fact);
            return(facts);
        }
예제 #4
0
        }       //	prepare

        /// <summary>
        /// Perrform Process.
        /// </summary>
        /// <returns>Message (clear text)</returns>
        protected override String DoIt()
        {
            log.Info("C_Project_ID=" + _C_Project_ID);
            if (_C_Project_ID == 0)
            {
                throw new ArgumentException("C_Project_ID == 0");
            }
            MProject fromProject = GetProject(GetCtx(), _C_Project_ID, Get_TrxName());

            GetCtx().SetIsSOTrx(true);          //	Set SO context

            /** @todo duplicate invoice prevention */

            MOrder order = new MOrder(fromProject, true, MOrder.DocSubTypeSO_OnCredit);

            if (!order.Save())
            {
                throw new Exception("Could not create Order");
            }

            //	***	Lines ***
            int count = 0;

            //	Service Project
            if (MProject.PROJECTCATEGORY_ServiceChargeProject.Equals(fromProject.GetProjectCategory()))
            {
                /** @todo service project invoicing */
                throw new Exception("Service Charge Projects are on the TODO List");
            }           //	Service Lines

            else        //	Order Lines
            {
                MProjectLine[] lines = fromProject.GetLines();
                for (int i = 0; i < lines.Length; i++)
                {
                    MOrderLine ol = new MOrderLine(order);
                    ol.SetLine(lines[i].GetLine());
                    ol.SetDescription(lines[i].GetDescription());
                    //
                    ol.SetM_Product_ID(lines[i].GetM_Product_ID(), true);

                    //ol.SetQty(lines[i].GetPlannedQty().subtract(lines[i].GetInvoicedQty()));
                    ol.SetQty(Decimal.Subtract(lines[i].GetPlannedQty(), lines[i].GetInvoicedQty()));
                    ol.SetPrice();
                    if (lines[i].GetPlannedPrice().CompareTo(Env.ZERO) != 0)
                    {
                        ol.SetPrice(lines[i].GetPlannedPrice());
                    }
                    ol.SetDiscount();
                    ol.SetTax();
                    if (ol.Save())
                    {
                        count++;
                    }
                }               //	for all lines
                if (lines.Length != count)
                {
                    log.Log(Level.SEVERE, "Lines difference - ProjectLines=" + lines.Length + " <> Saved=" + count);
                }
            }           //	Order Lines

            return("@C_Order_ID@ " + order.GetDocumentNo() + " (" + count + ")");
        }       //	doIt
예제 #5
0
        }       //	prepare

        /// <summary>
        /// Perrform Process.
        /// </summary>
        /// <returns>Message (clear text)</returns>
        protected override String DoIt()
        {
            log.Info("C_Project_ID=" + _C_Project_ID);
            if (_C_Project_ID == 0)
            {
                throw new ArgumentException("C_Project_ID == 0");
            }
            MProject fromProject = GetProject(GetCtx(), _C_Project_ID, Get_TrxName());

            GetCtx().SetIsSOTrx(true);  //	Set SO context

            /** @todo duplicate invoice prevention */
            //Added by Vivek for Credit Limit on 24/08/2016
            if (fromProject.GetC_BPartner_ID() != 0)
            {
                VAdvantage.Model.MBPartner bp = new VAdvantage.Model.MBPartner(GetCtx(), fromProject.GetC_BPartner_ID(), Get_TrxName());
                if (bp.GetCreditStatusSettingOn() == "CH")
                {
                    if (bp.GetCreditValidation() == "A" || bp.GetCreditValidation() == "D" || bp.GetCreditValidation() == "E")
                    {
                        log.SaveError("StopOrder", "");
                        return(Msg.GetMsg(GetCtx(), "StopOrder"));
                    }
                    else if (bp.GetCreditValidation() == "G" || bp.GetCreditValidation() == "J" || bp.GetCreditValidation() == "K")
                    {
                        if (_msg != null)
                        {
                            _msg.Clear();
                        }
                        log.SaveError("WarningOrder", "");
                        _msg.Append(Msg.GetMsg(GetCtx(), "WarningOrder"));
                    }
                }
                else
                {
                    VAdvantage.Model.MBPartnerLocation loc = new VAdvantage.Model.MBPartnerLocation(GetCtx(), fromProject.GetC_BPartner_Location_ID(), Get_TrxName());
                    if (loc.GetCreditValidation() == "A" || loc.GetCreditValidation() == "D" || loc.GetCreditValidation() == "E")
                    {
                        log.SaveError("StopOrder", "");
                        return(Msg.GetMsg(GetCtx(), "StopOrder"));
                    }
                    else if (loc.GetCreditValidation() == "G" || loc.GetCreditValidation() == "J" || loc.GetCreditValidation() == "K")
                    {
                        if (_msg != null)
                        {
                            _msg.Clear();
                        }
                        log.SaveError("WarningOrder", "");
                        _msg.Append(Msg.GetMsg(GetCtx(), "WarningOrder"));
                    }
                }
            }
            //Credit Limit
            MOrder order = new MOrder(fromProject, true, MOrder.DocSubTypeSO_OnCredit);

            if (!order.Save())
            {
                throw new Exception("Could not create Order");
            }

            //	***	Lines ***
            int count = 0;

            //	Service Project
            if (MProject.PROJECTCATEGORY_ServiceChargeProject.Equals(fromProject.GetProjectCategory()))
            {
                /** @todo service project invoicing */
                throw new Exception("Service Charge Projects are on the TODO List");
            }    //	Service Lines

            else //	Order Lines
            {
                MProjectLine[] lines = fromProject.GetLines();
                for (int i = 0; i < lines.Length; i++)
                {
                    MOrderLine ol = new MOrderLine(order);
                    ol.SetLine(lines[i].GetLine());
                    ol.SetDescription(lines[i].GetDescription());
                    //
                    ol.SetM_Product_ID(lines[i].GetM_Product_ID(), true);

                    //ol.SetQty(lines[i].GetPlannedQty().subtract(lines[i].GetInvoicedQty()));
                    ol.SetQty(Decimal.Subtract(lines[i].GetPlannedQty(), lines[i].GetInvoicedQty()));
                    ol.SetPrice();
                    if (lines[i].GetPlannedPrice().CompareTo(Env.ZERO) != 0)
                    {
                        ol.SetPrice(lines[i].GetPlannedPrice());
                    }
                    ol.SetDiscount();
                    ol.SetTax();
                    if (ol.Save())
                    {
                        count++;
                    }
                }       //	for all lines
                if (lines.Length != count)
                {
                    log.Log(Level.SEVERE, "Lines difference - ProjectLines=" + lines.Length + " <> Saved=" + count);
                }
            }   //	Order Lines
            if (_msg != null)
            {
                return("@C_Order_ID@ " + order.GetDocumentNo() + " (" + count + ")" + "  " + _msg);
            }
            else
            {
                return("@C_Order_ID@ " + order.GetDocumentNo() + " (" + count + ")");
            }
        }       //	doIt