/// <summary> /// Add BOM Line to this. /// Calls addBOMLines if added product is a BOM /// </summary> /// <param name="line">BOM Line</param> /// <param name="qty">quantity</param> private void AddBOMLine(Ctx ctx, MProductBOM line, Decimal qty) { // Envs.SetBusyIndicator(true); log.Fine(line.ToString()); String bomType = line.GetBOMType(); if (bomType == null) { bomType = MProductBOM.BOMTYPE_StandardPart; } // Decimal lineQty = Decimal.Multiply(line.GetBOMQty(), qty); MProduct product = line.GetProduct(); if (product == null) { return; } if (product.IsBOM() && product.IsVerified()) { BomLines(ctx, product, lineQty); } else { // GetDisplay(line.GetM_Product_ID(), // product.GetM_Product_ID(), bomType, product.GetName(), lineQty); } }
/// <summary> /// Validate Old BOM Product structure /// </summary> /// <param name="product">product</param> /// <returns>true if valid</returns> private bool ValidateOldProduct(MProduct product) { if (!product.IsBOM()) { return(true); } // if (_products.Contains(product)) { log.Warning(_product.GetName() + " recursively includes " + product.GetName()); return(false); } _products.Add(product); log.Fine(product.GetName()); // MProductBOM[] productsBOMs = MProductBOM.GetBOMLines(product); for (int i = 0; i < productsBOMs.Length; i++) { MProductBOM productsBOM = productsBOMs[i]; MProduct pp = new MProduct(GetCtx(), productsBOM.GetM_ProductBOM_ID(), Get_Trx()); if (!pp.IsBOM()) { log.Finer(pp.GetName()); } else if (!ValidateOldProduct(pp)) { return(false); } } return(true); }
/// <summary> /// Validate Product /// </summary> /// <param name="product">product</param> /// <returns>Info</returns> private String ValidateProduct(MProduct product) { if (!product.IsBOM()) { return(product.GetName() + " @NotValid@ @M_BOM_ID@"); } _product = product; // Check Old Product BOM Structure log.Config(_product.GetName()); _products = new List <MProduct>(); if (!ValidateOldProduct(_product)) { _product.SetIsVerified(false); _product.Save(); return(_product.GetName() + " @NotValid@"); } // New Structure MBOM[] boms = MBOM.GetOfProduct(GetCtx(), _M_Product_ID, Get_Trx(), null); for (int i = 0; i < boms.Length; i++) { _products = new List <MProduct>(); if (!ValidateBOM(boms[i])) { _product.SetIsVerified(false); _product.Save(); return(_product.GetName() + " " + boms[i].GetName() + " @NotValid@"); } } // OK _product.SetIsVerified(true); _product.Save(); return(_product.GetName() + " @IsValid@"); }
/// <summary> /// Validate BOM /// </summary> /// <param name="bom">bom</param> /// <returns>true if valid</returns> private bool ValidateBOM(MBOM bom) { MBOMProduct[] BOMproducts = MBOMProduct.GetOfBOM(bom); for (int i = 0; i < BOMproducts.Length; i++) { MBOMProduct BOMproduct = BOMproducts[i]; MProduct pp = new MProduct(GetCtx(), BOMproduct.GetM_BOMProduct_ID(), Get_Trx()); if (pp.IsBOM()) { return(ValidateProduct(pp, bom.GetBOMType(), bom.GetBOMUse())); } } return(true); }
/// <summary> /// Validate Product /// </summary> /// <param name="product">product</param> /// <returns>Info</returns> private String ValidateProduct(MProduct product) { if (!product.IsBOM()) { return(product.GetName() + " @NotValid@ @M_BOM_ID@"); } _product = product; // Check Old Product BOM Structure log.Config(_product.GetName()); _products = new List <MProduct>(); if (!ValidateOldProduct(_product)) { _product.SetIsVerified(false); _product.Save(); return(_product.GetName() + " @NotValid@"); } // New Structure MBOM[] boms = MBOM.GetOfProduct(GetCtx(), _M_Product_ID, Get_Trx(), null); for (int i = 0; i < boms.Length; i++) { //When BOM Type = Manufacturing then system will not allow to verify the BOM if sum of component is less or greater then 1 if (boms[i].GetBOMUse() == "M") { _product = product; Decimal count = Util.GetValueOfDecimal(DB.ExecuteScalar("SELECT SUM(BOMQty) FROM M_BOMProduct WHERE IsActive = 'Y' AND M_BOM_ID=" + boms[i].GetM_BOM_ID(), null, null)); if (count != 1) { _product.SetIsVerified(false); _product.Save(); return(_product.GetName() + " " + boms[i].GetName() + " @NotValid@"); } } _products = new List <MProduct>(); if (!ValidateBOM(boms[i])) { _product.SetIsVerified(false); _product.Save(); return(_product.GetName() + " " + boms[i].GetName() + " @NotValid@"); } } // OK _product.SetIsVerified(true); _product.Save(); return(_product.GetName() + " @IsValid@"); }
/// <summary> /// Validate Product /// </summary> /// <param name="product">product</param> /// <returns>Info</returns> private String ValidateProduct(MProduct product) { count = Util.GetValueOfInt(DB.ExecuteScalar(@"SELECT COUNT(*) FROM AD_MODULEINFO WHERE IsActive = 'Y' AND PREFIX ='VAMFG_'")); if (!product.IsBOM()) { return(product.GetName() + " @NotValid@ @M_BOM_ID@"); } _product = product; // Check Old Product BOM Structure log.Config(_product.GetName()); _products = new List <MProduct>(); if (!ValidateOldProduct(_product)) { _product.SetIsVerified(false); _product.Save(); return(_product.GetName() + " @NotValid@"); } // New Structure MBOM[] boms = MBOM.GetOfProduct(GetCtx(), _M_Product_ID, Get_Trx(), null); // if manufacturing module exist and BOM not contain any record against this product then not to verify Product if (count > 0 && boms.Length == 0) { _product.SetIsVerified(false); _product.Save(); return(_product.GetName() + " @NotValid@"); } for (int i = 0; i < boms.Length; i++) { _products = new List <MProduct>(); if (!ValidateBOM(boms[i])) { _product.SetIsVerified(false); _product.Save(); return(_product.GetName() + " " + boms[i].GetName() + " @NotValid@"); } } // OK _product.SetIsVerified(true); _product.Save(); return(_product.GetName() + " @IsValid@"); }
/// <summary> /// Validate BOM /// </summary> /// <param name="bom">bom</param> /// <returns>true if valid</returns> private bool ValidateBOM(MBOM bom) { count = Util.GetValueOfInt(DB.ExecuteScalar(@"SELECT COUNT(*) FROM AD_MODULEINFO WHERE IsActive = 'Y' AND PREFIX ='VAMFG_'")); MBOMProduct[] BOMproducts = MBOMProduct.GetOfBOM(bom); // if manufacturing module exist and BOM Componet not contain any record against this BOM then not to verify Product if (count > 0 && BOMproducts.Length == 0) { return(false); } for (int i = 0; i < BOMproducts.Length; i++) { MBOMProduct BOMproduct = BOMproducts[i]; MProduct pp = new MProduct(GetCtx(), BOMproduct.GetM_BOMProduct_ID(), Get_Trx()); if (pp.IsBOM()) { return(ValidateProduct(pp, bom.GetBOMType(), bom.GetBOMUse())); } } return(true); }
/// <summary> /// Validate Product /// </summary> /// <param name="product">product</param> /// <param name="BOMType"></param> /// <param name="BOMUse"></param> /// <returns>true if valid</returns> private bool ValidateProduct(MProduct product, String BOMType, String BOMUse) { if (!product.IsBOM()) { return(true); } // String restriction = "BOMType='" + BOMType + "' AND BOMUse='" + BOMUse + "'"; MBOM[] boms = MBOM.GetOfProduct(GetCtx(), _M_Product_ID, Get_Trx(), restriction); if (boms.Length != 1) { log.Warning(restriction + " - Length=" + boms.Length); return(false); } if (_products.Contains(product)) { log.Warning(_product.GetName() + " recursively includes " + product.GetName()); return(false); } _products.Add(product); log.Fine(product.GetName()); // MBOM bom = boms[0]; MBOMProduct[] BOMproducts = MBOMProduct.GetOfBOM(bom); for (int i = 0; i < BOMproducts.Length; i++) { MBOMProduct BOMproduct = BOMproducts[i]; MProduct pp = new MProduct(GetCtx(), BOMproduct.GetM_BOMProduct_ID(), Get_Trx()); if (pp.IsBOM()) { return(ValidateProduct(pp, bom.GetBOMType(), bom.GetBOMUse())); } } return(true); }
/// <summary> /// Validate Old BOM Product structure /// </summary> /// <param name="product">product</param> /// <returns>true if valid</returns> private bool ValidateOldProduct(MProduct product) { count = Util.GetValueOfInt(DB.ExecuteScalar(@"SELECT COUNT(*) FROM AD_MODULEINFO WHERE IsActive = 'Y' AND PREFIX ='VAMFG_'")); if (!product.IsBOM()) { return(true); } // if (_products.Contains(product)) { log.Warning(_product.GetName() + " recursively includes " + product.GetName()); return(false); } _products.Add(product); log.Fine(product.GetName()); // MProductBOM[] productsBOMs = MProductBOM.GetBOMLines(product); // if manufacturing module not exist and Product BOM not containany record against this product thennot to verify BOM if (count <= 0 && productsBOMs.Length == 0) { return(false); } for (int i = 0; i < productsBOMs.Length; i++) { MProductBOM productsBOM = productsBOMs[i]; MProduct pp = new MProduct(GetCtx(), productsBOM.GetM_ProductBOM_ID(), Get_Trx()); if (!pp.IsBOM()) { log.Finer(pp.GetName()); } else if (!ValidateOldProduct(pp)) { return(false); } } return(true); }