public Dictionary <string, string> GetCategoryData(Ctx ctx, string fields)
        {
            string[] paramValue            = fields.Split(',');
            int      M_Product_Category_ID = 0;

            M_Product_Category_ID = Util.GetValueOfInt(paramValue[0].ToString());
            MProductCategory            pc     = new MProductCategory(ctx, M_Product_Category_ID, null);
            Dictionary <string, string> retDic = new Dictionary <string, string>();

            if (pc.Get_ColumnIndex("ProductType") > 0)
            {
                retDic["ProductType"] = pc.GetProductType();
            }
            if (pc.Get_ColumnIndex("M_AttributeSet_ID") > 0)
            {
                retDic["M_AttributeSet_ID"] = Util.GetValueOfString(pc.GetM_AttributeSet_ID());
            }
            if (pc.Get_ColumnIndex("C_TaxCategory_ID") > 0)
            {
                retDic["C_TaxCategory_ID"] = Util.GetValueOfString(pc.GetC_TaxCategory_ID());
            }
            retDic["A_Asset_Group_ID"] = Util.GetValueOfString(pc.GetA_Asset_Group_ID());
            if (pc.GetA_Asset_Group_ID() > 0)
            {
                MAssetGroup astGrp = new MAssetGroup(ctx, pc.GetA_Asset_Group_ID(), null);
                if (astGrp.Get_ColumnIndex("VA038_AmortizationTemplate_ID") > 0)
                {
                    retDic["VA038_AmortizationTemplate_ID"] = Util.GetValueOfString(astGrp.Get_Value("VA038_AmortizationTemplate_ID"));
                }
            }
            return(retDic);
        }
Exemplo n.º 2
0
        /**
         *  Create One Asset Per UOM
         *	@return individual asset
         */
        public bool IsOneAssetPerUOM()
        {
            MProductCategory pc = MProductCategory.Get(GetCtx(), GetM_Product_Category_ID());

            if (!Env.IsModuleInstalled("INT16_"))
            {
                if (pc.GetA_Asset_Group_ID() == 0)
                {
                    return(false);
                }
                MAssetGroup ag = MAssetGroup.Get(GetCtx(), pc.GetA_Asset_Group_ID());
                return(ag.IsOneAssetPerUOM());
            }
            else
            {
                return(Convert.ToBoolean(pc.Get_Value("INT16_IsOneAssetPerUOM")));
            }
        }
 /**
  *  Get Asset Group
  *	@return asset Group
  */
 public MAssetGroup GetAssetGroup()
 {
     return(MAssetGroup.Get(GetCtx(), GetA_Asset_Group_ID()));
 }
        // Create Asset From Invoice Mohit

        /**
         *  Shipment Constructor
         *  @param Invoice
         *	@param shipLine shipment line
         *	@param deliveryCount 0 or number of delivery
         */
        public MAsset(MInvoice invoice, MInvoiceLine invoiceline, int deliveryCount)
            : this(invoiceline.GetCtx(), 0, invoiceline.Get_TrxName())
        {
            SetClientOrg(invoiceline);

            SetValueNameDescription(invoice, invoiceline, deliveryCount);
            //	Header

            //SetIsOwned(true);
            SetC_BPartner_ID(invoice.GetC_BPartner_ID());
            SetC_BPartner_Location_ID(invoice.GetC_BPartner_Location_ID());
            SetAD_User_ID(invoice.GetAD_User_ID());
            //SetM_Locator_ID(invoice.GetM_Locator_ID());
            SetIsInPosession(true);


            SetAssetServiceDate(invoice.GetDateAcct());


            //	Line
            MProduct product = invoiceline.GetProduct();

            SetM_Product_ID(product.GetM_Product_ID());
            SetA_Asset_Group_ID(product.GetA_Asset_Group_ID());

            //////////////////////////////*
            //Changes for vafam
            // SetAssetServiceDate(shipment.GetMovementDate());
            //SetGuaranteeDate(TimeUtil.AddDays(shipment.GetMovementDate(), product.GetGuaranteeDays()));
            MAssetGroup _assetGroup = new MAssetGroup(GetCtx(), GetA_Asset_Group_ID(), invoice.Get_TrxName());

            if (_assetGroup.IsOwned())
            {
                SetIsOwned(true);
                //SetC_BPartner_ID(0);
            }
            if (_assetGroup.IsDepreciated())
            {
                SetIsDepreciated(true);
                SetIsFullyDepreciated(false);
            }
            ////////////////////////////////////

            //Change by Sukhwinder for setting Asset type and amortization template on Asset window, MANTIS ID:1762
            int countVA038 = Util.GetValueOfInt(DB.ExecuteScalar("SELECT COUNT(AD_MODULEINFO_ID) FROM AD_MODULEINFO WHERE PREFIX='VA038_' "));

            Set_Value("VAFAM_AssetType", _assetGroup.Get_Value("VAFAM_AssetType").ToString());
            if (countVA038 > 0)
            {
                Set_Value("VA038_AmortizationTemplate_ID", VAdvantage.Utility.Util.GetValueOfInt(_assetGroup.Get_Value("VA038_AmortizationTemplate_ID")));
            }
            Set_Value("VAFAM_DepreciationType_ID", VAdvantage.Utility.Util.GetValueOfInt(_assetGroup.Get_Value("VAFAM_DepreciationType_ID")));

            ////////////////////////////////////

            //	Guarantee & Version
            SetGuaranteeDate(TimeUtil.AddDays(invoice.GetDateInvoiced(), product.GetGuaranteeDays()));
            SetVersionNo(product.GetVersionNo());
            if (invoiceline.GetM_AttributeSetInstance_ID() != 0)                //	Instance
            {
                MAttributeSetInstance asi = new MAttributeSetInstance(GetCtx(), invoiceline.GetM_AttributeSetInstance_ID(), Get_TrxName());
                SetM_AttributeSetInstance_ID(asi.GetM_AttributeSetInstance_ID());
                SetLot(asi.GetLot());
                SetSerNo(asi.GetSerNo());
            }
            SetHelp(invoiceline.GetDescription());
            //	Qty
            int units = product.GetSupportUnits();

            if (units == 0)
            {
                units = 1;
            }
            if (deliveryCount != 0)             //	one asset per UOM
            {
                SetQty(invoiceline.GetQtyEntered(), units);
            }
            else
            {
                SetQty((Decimal)units);
            }
            SetM_InOutLine_ID(invoiceline.GetM_InOutLine_ID());
            Set_Value("C_InvoiceLine_ID", invoiceline.GetC_InvoiceLine_ID());

            //	Activate
            MAssetGroup ag = MAssetGroup.Get(GetCtx(), GetA_Asset_Group_ID());

            if (!ag.IsCreateAsActive())
            {
                SetIsActive(false);
            }
        }