예제 #1
0
        /// <summary>
        /// Process
        /// </summary>
        /// <returns>info</returns>
        protected override String DoIt()
        {
            log.Info("M_Product_Category_ID=" + _M_Product_Category_ID
                     + ", Future=" + _SetFutureCostTo
                     + ", Standard=" + _SetStandardCostTo
                     + "; M_PriceList_Version_ID=" + _M_PriceList_Version_ID);
            if (_SetFutureCostTo == null)
            {
                _SetFutureCostTo = "";
            }
            if (_SetStandardCostTo == null)
            {
                _SetStandardCostTo = "";
            }
            //	Nothing to Do
            if (_SetFutureCostTo.Length == 0 && _SetStandardCostTo.Length == 0)
            {
                return("-");
            }
            //	PLV required
            if (_M_PriceList_Version_ID == 0 &&
                (_SetFutureCostTo.Equals(TO_PriceListLimit) || _SetStandardCostTo.Equals(TO_PriceListLimit)))
            {
                throw new Exception("@FillMandatory@  @M_PriceList_Version_ID@");
            }

            //	Validate Source
            if (!IsValid(_SetFutureCostTo))
            {
                throw new Exception("@NotFound@ @M_CostElement_ID@ (Future) " + _SetFutureCostTo);
            }
            if (!IsValid(_SetStandardCostTo))
            {
                throw new Exception("@NotFound@ @M_CostElement_ID@ (Standard) " + _SetStandardCostTo);
            }

            //	Prepare
            MClient client = MClient.Get(GetCtx());

            _ce = MCostElement.GetMaterialCostElement(client, MAcctSchema.COSTINGMETHOD_StandardCosting);
            if (_ce.Get_ID() == 0)
            {
                throw new Exception("@NotFound@ @M_CostElement_ID@ (StdCost)");
            }
            log.Config(_ce.ToString());
            _ass = MAcctSchema.GetClientAcctSchema(GetCtx(), client.GetAD_Client_ID());
            for (int i = 0; i < _ass.Length; i++)
            {
                CreateNew(_ass[i]);
            }
            Commit();

            //	Update Cost
            int counter = Update();

            return("#" + counter);
        }
예제 #2
0
        public override String LoadDocumentDetails()
        {
            costupdate = (MCostUpdate)GetPO();
            if (costupdate.GetM_Product_Category_ID() != 0)
            {
                mpc = MProductCategory.Get(GetCtx(), costupdate.GetM_Product_Category_ID());
            }

            _lines = LoadLines(costupdate);
            m_ce   = MCostElement.GetMaterialCostElement(MClient.Get(GetCtx()), X_C_AcctSchema.COSTINGMETHOD_StandardCosting);
            SetDateAcct(costupdate.GetDateAcct());
            SetDateDoc(costupdate.GetDateAcct());
            return(null);
        }
예제 #3
0
        /// <summary>
        /// Get Cost Element
        /// </summary>
        /// <param name="CostingMethod">method</param>
        /// <returns>costing element or null</returns>
        private MCostElement GetCostElement(String CostingMethod)
        {
            MCostElement ce = null;

            //if (_ces.Count == 0)
            //{
            //    ce = null;
            //}
            //else
            //{
            //    ce = _ces[CostingMethod];// _ces.get(CostingMethod);
            //}
            if (_ces.ContainsKey(CostingMethod))
            {
                ce = _ces[CostingMethod];// _ces.get(CostingMethod);
            }
            if (ce == null)
            {
                ce = MCostElement.GetMaterialCostElement(GetCtx(), CostingMethod);
                //_ces.put(CostingMethod, ce);
                _ces.Add(CostingMethod, ce);
            }
            return(ce);
        }