/** * Complete Document * @return new status (Complete, In Progress, Invalid, Waiting ..) */ public String CompleteIt() { try { // Re-Check if (!_justPrepared) { String status = PrepareIt(); if (!DocActionVariables.STATUS_INPROGRESS.Equals(status)) { return(status); } } // JID_1290: Set the document number from completed document sequence after completed (if needed) SetCompletedDocumentNo(); // Implicit Approval if (!IsApproved()) { ApproveIt(); } log.Info(ToString()); // User Validation String valid = ModelValidationEngine.Get().FireDocValidate(this, ModalValidatorVariables.DOCTIMING_AFTER_COMPLETE); if (valid != null) { _processMsg = valid; return(DocActionVariables.STATUS_INVALID); } // SetProcessed(true); SetDocAction(DocActionVariables.ACTION_CLOSE); /**************************************************************************************************************/ // Check Column Name new 6jan 0 vikas int _count = Util.GetValueOfInt(DB.ExecuteScalar(" SELECT Count(*) FROM AD_Column WHERE columnname = 'DTD001_SourceReserve' ")); Tuple <String, String, String> mInfo = null; if (Env.HasModulePrefix("DTD001_", out mInfo)) { MRequisitionLine[] lines = GetLines(); MProduct product = null; for (int i = 0; i < lines.Length; i++) { MRequisitionLine line = lines[i]; if (line.GetM_Product_ID() > 0) { product = MProduct.Get(GetCtx(), line.GetM_Product_ID()); } int loc_id = GetLocation(GetM_Warehouse_ID()); //new 6jan 1 int Sourcewhloc_id = GetSwhLocation(GetDTD001_MWarehouseSource_ID()); if (Sourcewhloc_id == 0) { // JID_1098: done by Bharat on 31 Jan 2019, need to correct these messages _processMsg = Msg.GetMsg(GetCtx(), "DTD001_DefineSrcLocator"); //"Define Locator For That SourceWarehouse"; return(DocActionVariables.STATUS_INVALID); } //End if (loc_id == 0) { //return Msg.GetMsg(GetCtx(),"MMPM_DefineLocator"); _processMsg = Msg.GetMsg(GetCtx(), "DTD001_DefineLocator"); //"Define Locator For That Warehouse"; return(DocActionVariables.STATUS_INVALID); } if (line.Get_ColumnIndex("OrderLocator_ID") > 0) { line.SetOrderLocator_ID(loc_id); line.SetReserveLocator_ID(Sourcewhloc_id); if (!line.Save()) { _processMsg = Msg.GetMsg(GetCtx(), "ReqLineNotSaved"); return(DocActionVariables.STATUS_INVALID); } } //if (Util.GetValueOfInt(DB.ExecuteScalar("SELECT COUNT(AD_MODULEINFO_ID) FROM AD_MODULEINFO WHERE PREFIX='VA203_'", null, null)) > 0) // SI_0686_2 : storage should not update in case of product is other than item type. if (Env.IsModuleInstalled("VA203_") && product != null && product.GetProductType() == X_M_Product.PRODUCTTYPE_Item) { storage = MStorage.Get(GetCtx(), loc_id, line.GetM_Product_ID(), line.GetM_AttributeSetInstance_ID(), Get_Trx()); if (storage == null) { storage = MStorage.GetCreate(GetCtx(), loc_id, line.GetM_Product_ID(), line.GetM_AttributeSetInstance_ID(), Get_Trx()); } storage.SetDTD001_QtyReserved((Decimal.Add(storage.GetDTD001_QtyReserved(), (Decimal)line.GetQty()))); if (!storage.Save()) { log.Info("Requisition Reserverd Quantity not saved at storage at locator " + loc_id + " and product is " + line.GetM_Product_ID()); } ///new 6jan 2 if (_count > 0) { Swhstorage = MStorage.Get(GetCtx(), Sourcewhloc_id, line.GetM_Product_ID(), line.GetM_AttributeSetInstance_ID(), Get_Trx()); if (Swhstorage == null) { Swhstorage = MStorage.GetCreate(GetCtx(), Sourcewhloc_id, line.GetM_Product_ID(), line.GetM_AttributeSetInstance_ID(), Get_Trx()); } Swhstorage.SetDTD001_SourceReserve((Decimal.Add(Swhstorage.GetDTD001_SourceReserve(), (Decimal)line.GetQty()))); if (!Swhstorage.Save()) { log.Info("Requisition Reserverd Quantity not saved at storage at locator " + Sourcewhloc_id + " and product is " + line.GetM_Product_ID()); } } //End } else if (product != null && product.GetProductType() == X_M_Product.PRODUCTTYPE_Item) { // SI_0657: consider Attribute also storage = MStorage.Get(GetCtx(), loc_id, line.GetM_Product_ID(), line.GetM_AttributeSetInstance_ID(), Get_Trx()); if (storage == null) { //MStorage.Add(GetCtx(), GetM_Warehouse_ID(), loc_id, line.GetM_Product_ID(), 0, 0, 0, 0, line.GetQty(), null); MStorage.Add(GetCtx(), GetM_Warehouse_ID(), loc_id, line.GetM_Product_ID(), line.GetM_AttributeSetInstance_ID(), line.GetM_AttributeSetInstance_ID(), (Decimal)0, (Decimal)0, (Decimal)0, line.GetQty(), Get_Trx()); } else { storage.SetDTD001_QtyReserved((Decimal.Add(storage.GetDTD001_QtyReserved(), (Decimal)line.GetQty()))); storage.Save(); } //new 6jan 3 if (_count > 0) { Swhstorage = MStorage.Get(GetCtx(), Sourcewhloc_id, line.GetM_Product_ID(), line.GetM_AttributeSetInstance_ID(), Get_Trx()); if (Swhstorage == null) { MStorage.Add(GetCtx(), GetDTD001_MWarehouseSource_ID(), Sourcewhloc_id, line.GetM_Product_ID(), line.GetM_AttributeSetInstance_ID(), line.GetM_AttributeSetInstance_ID(), (Decimal)0, (Decimal)0, (Decimal)0, 0, Get_Trx()); MStorage StrgResrvQty = null; StrgResrvQty = MStorage.GetCreate(GetCtx(), Sourcewhloc_id, line.GetM_Product_ID(), line.GetM_AttributeSetInstance_ID(), Get_Trx()); StrgResrvQty.SetDTD001_SourceReserve(Decimal.Add(StrgResrvQty.GetDTD001_SourceReserve(), line.GetQty())); StrgResrvQty.Save(); } else { Swhstorage.SetDTD001_SourceReserve((Decimal.Add(Swhstorage.GetDTD001_SourceReserve(), (Decimal)line.GetQty()))); Swhstorage.Save(); } } //End } } } } catch (Exception ex) { //MessageBox.Show("MRequisition--CompleteIt"); log.Severe(ex.ToString()); } return(DocActionVariables.STATUS_COMPLETED); }