예제 #1
0
        /**
         *  Set Value, Name, Description
         *	@param invoice
         *	@param deliveryCount count
         *	@param product product
         *	@param partner partner
         */
        public void SetValueNameDescription(MInvoice invoice,
                                            int deliveryCount, MProduct product, MBPartner partner)
        {
            String documentNo = "_" + invoice.GetDocumentNo();

            if (deliveryCount > 1)
            {
                documentNo += "_" + deliveryCount;
            }
            //	Value
            String value = partner.GetValue() + "_" + product.GetValue();

            if (value.Length > 40 - documentNo.Length)
            {
                value = value.Substring(0, 40 - documentNo.Length) + documentNo;
            }
            // Change to set Value from Document Sequence
            // SetValue(value);

            // Change to set only name of product as value in Asset
            //	Name		MProduct.afterSave
            // String name = partner.GetName() + " - " + product.GetName();

            String name = product.GetName();

            if (name.Length > 60)
            {
                name = name.Substring(0, 60);
            }
            SetName(name);
            //	Description
            String description = product.GetDescription();

            SetDescription(description);
        }
예제 #2
0
        protected override bool AfterDelete(bool success)
        {
            // when we delete BOM, then set IsVerified False on Product
            MProduct product = new MProduct(GetCtx(), GetM_Product_ID(), Get_Trx());

            product.SetIsVerified(false);
            if (!product.Save())
            {
                log.SaveError("Error", "Verified not updated on Product : " + product.GetValue());
            }
            return(true);
        }
예제 #3
0
        }       //	beforeSave

        protected override bool AfterSave(bool newRecord, bool success)
        {
            //set verified on Product as False when we change BOMType AND BOMUse
            if (newRecord || Is_ValueChanged("BOMType") || Is_ValueChanged("BOMUse") || Is_ValueChanged("IsActive") || Is_ValueChanged("M_AttributeSetInstance_ID"))
            {
                MProduct product = new MProduct(GetCtx(), GetM_Product_ID(), Get_Trx());
                product.SetIsVerified(false);
                if (!product.Save())
                {
                    log.SaveError("Error", "Verified not updated on Product : " + product.GetValue());
                }
            }
            return(true);
        }
예제 #4
0
        /**
         *  Create Trial Asset
         *	@param ctx context
         *	@param user user
         *	@param entityType entity type
         *	@return asset or null if no product found
         */
        public static MAsset GetTrial(Ctx ctx, MUser user, String entityType)
        {
            if (user == null)
            {
                _log.Warning("Cannot create Trial - No User");
                return(null);
            }
            if (Utility.Util.IsEmpty(entityType))
            {
                _log.Warning("Cannot create Trial - No Entity Type");
                return(null);
            }
            MProduct product = MProduct.GetTrial(ctx, entityType);

            if (product == null)
            {
                _log.Warning("No Trial for Entity Type=" + entityType);
                return(null);
            }
            //
            DateTime now = Convert.ToDateTime(CommonFunctions.CurrentTimeMillis());
            //
            MAsset asset = new MAsset(ctx, 0, null);

            asset.SetClientOrg(user);
            asset.SetAssetServiceDate(now);
            asset.SetIsOwned(false);
            asset.SetIsTrialPhase(true);
            //
            MBPartner partner    = new MBPartner(ctx, user.GetC_BPartner_ID(), null);
            String    documentNo = "Trial";
            //	Value
            String value = partner.GetValue() + "_" + product.GetValue();

            if (value.Length > 40 - documentNo.Length)
            {
                value = value.Substring(0, 40 - documentNo.Length) + documentNo;
            }
            asset.SetValue(value);
            //	Name		MProduct.afterSave
            String name = "Trial " + partner.GetName() + " - " + product.GetName();

            if (name.Length > 60)
            {
                name = name.Substring(0, 60);
            }
            asset.SetName(name);
            //	Description
            String description = product.GetDescription();

            asset.SetDescription(description);

            //	User
            asset.SetAD_User_ID(user.GetAD_User_ID());
            asset.SetC_BPartner_ID(user.GetC_BPartner_ID());
            //	Product
            asset.SetM_Product_ID(product.GetM_Product_ID());
            asset.SetA_Asset_Group_ID(product.GetA_Asset_Group_ID());
            asset.SetQty(new Decimal(product.GetSupportUnits()));
            //	Guarantee & Version
            asset.SetGuaranteeDate(TimeUtil.AddDays(now, product.GetTrialPhaseDays()));
            asset.SetVersionNo(product.GetVersionNo());
            //
            return(asset);
        }