} // toString /// <summary> /// Get Document Info /// </summary> /// <returns>document info (untranslated)</returns> public String GetDocumentInfo() { MDocType dt = MDocType.Get(GetCtx(), GetC_DocType_ID()); return(dt.GetName() + " " + GetDocumentNo()); } // getDocumentInfo
/// <summary> /// Perform Process. /// </summary> /// <returns>Message (clear text)</returns> protected override String DoIt() { log.Info("C_Order_ID=" + _C_Order_ID + ", C_DocType_ID=" + _C_DocType_ID + ", CloseDocument=" + _IsCloseDocument); if (_C_Order_ID == 0) { throw new ArgumentException("No Order"); } VAdvantage.Model.MDocType dt = VAdvantage.Model.MDocType.Get(GetCtx(), _C_DocType_ID); if (dt.Get_ID() == 0) { throw new ArgumentException("No DocType"); } if (_DateDoc == null) { _DateDoc = Util.GetValueOfDateTime(DateTime.Now); } // VAdvantage.Model.MOrder from = new VAdvantage.Model.MOrder(GetCtx(), _C_Order_ID, Get_Trx()); if (from.GetDocStatus() != "DR" && from.GetDocStatus() != "IP" && from.GetDocStatus() != "CO") { throw new Exception("Order Closed"); } //JID_1799 fromCreateSo is true if DOCBASETYPE='BOO' VAdvantage.Model.MOrder newOrder = VAdvantage.Model.MOrder.CopyFrom(from, _DateDoc, dt.GetC_DocType_ID(), false, true, null, dt.GetDocBaseType().Equals(MDocBaseType.DOCBASETYPE_BLANKETSALESORDER) ? true : false); // copy ASI newOrder.SetC_DocTypeTarget_ID(_C_DocType_ID); int C_Bpartner_ID = newOrder.GetC_BPartner_ID(); newOrder.Set_Value("IsSalesQuotation", false); // Added by Bharat on 05 Jan 2018 to set Values on Blanket Sales Order from Sales Quotation. if (dt.GetDocBaseType() == "BOO") { newOrder.Set_Value("IsBlanketTrx", true); } else // Added by Bharat on 29 March 2018 to set Blanket Order zero in case of Sales order Creation. { newOrder.SetC_Order_Blanket(0); } if (newOrder.Get_ColumnIndex("C_Order_Quotation") > 0) { newOrder.SetC_Order_Quotation(_C_Order_ID); } //Update New Order Refrence From Sales Qutation in Sales order newOrder.SetPOReference(Util.GetValueOfString(from.GetDocumentNo())); // Added by Bharat on 31 Jan 2018 to set Inco Term from Quotation if (newOrder.Get_ColumnIndex("C_IncoTerm_ID") > 0) { newOrder.SetC_IncoTerm_ID(from.GetC_IncoTerm_ID()); } String sqlbp = "update c_project set c_bpartner_id=" + C_Bpartner_ID + " where ref_order_id=" + _C_Order_ID + ""; int value = DB.ExecuteQuery(sqlbp, null, Get_Trx()); bool OK = newOrder.Save(); if (!OK) { //return GetReterivedError( newOrder, "Could not create new Order"); throw new Exception("Could not create new Order"); } if (OK) { string sql = "select C_Project_id from c_project where c_order_id = " + from.GetC_Order_ID(); int C_Project_ID = Util.GetValueOfInt(DB.ExecuteScalar(sql, null, Get_Trx())); if (C_Project_ID != 0) { VAdvantage.Model.X_C_Project project = new VAdvantage.Model.X_C_Project(GetCtx(), C_Project_ID, Get_Trx()); project.SetC_BPartner_ID(project.GetC_BPartnerSR_ID()); project.SetC_BPartnerSR_ID(0); if (!project.Save()) { log.SaveError("Error on " + project.Get_TableName(), ""); } } if (dt.GetDocBaseType() == "BOO") { from.SetC_Order_Blanket(newOrder.GetC_Order_ID()); } else { from.SetRef_Order_ID(newOrder.GetC_Order_ID()); } from.Save(); int bp = newOrder.GetC_BPartner_ID(); VAdvantage.Model.X_C_BPartner prosp = new VAdvantage.Model.X_C_BPartner(GetCtx(), bp, Get_Trx()); prosp.SetIsCustomer(true); prosp.SetIsProspect(false); if (!prosp.Save()) { log.SaveError("Error on " + prosp.Get_TableName(), ""); } } // if (_IsCloseDocument) { VAdvantage.Model.MOrder original = new VAdvantage.Model.MOrder(GetCtx(), _C_Order_ID, Get_Trx()); //Edited by Arpit Rai on 8th of Nov,2017 if (original.GetDocStatus() != "CO") //to check if document is already completed { original.SetDocAction(VAdvantage.Model.MOrder.DOCACTION_Complete); original.ProcessIt(VAdvantage.Model.MOrder.DOCACTION_Complete); original.Save(); } //Arpit original.SetDocAction(VAdvantage.Model.MOrder.DOCACTION_Close); original.ProcessIt(VAdvantage.Model.MOrder.DOCACTION_Close); original.Save(); } // return(Msg.GetMsg(GetCtx(), "OrderCreatedSuccessfully") + " - " + dt.GetName() + ": " + newOrder.GetDocumentNo()); }
/// <summary> /// Perform Process. /// </summary> /// <returns>Message (clear text)</returns> protected override String DoIt() { log.Info("C_Order_ID=" + _C_Order_ID + ", C_DocType_ID=" + _C_DocType_ID + ", CloseDocument=" + _IsCloseDocument); if (_C_Order_ID == 0) { throw new ArgumentException("No Order"); } VAdvantage.Model.MDocType dt = VAdvantage.Model.MDocType.Get(GetCtx(), _C_DocType_ID); if (dt.Get_ID() == 0) { throw new ArgumentException("No DocType"); } if (_DateDoc == null) { _DateDoc = Util.GetValueOfDateTime(DateTime.Now); } // VAdvantage.Model.MOrder from = new VAdvantage.Model.MOrder(GetCtx(), _C_Order_ID, Get_Trx()); if (from.GetDocStatus() != "DR" && from.GetDocStatus() != "IP" && from.GetDocStatus() != "CO") { throw new Exception("Order Closed"); } //Develop by Deekshant For check VA077 Module For spilt the Sales Order if (VAdvantage.Utility.Env.IsModuleInstalled("VA077_")) { //Check Destination Organization in c_orderline string str = "SELECT DISTINCT(VA077_DestinationOrg), AD_Org_Id FROM C_OrderLine WHERE C_Order_ID=" + _C_Order_ID; DataSet dts = DB.ExecuteDataset(str, null, Get_Trx()); if (dts != null && dts.Tables[0].Rows.Count > 0) { for (int i = 0; i < dts.Tables[0].Rows.Count; i++) { int destinationorg = Util.GetValueOfInt(dts.Tables[0].Rows[i]["VA077_DestinationOrg"]); // VAdvantage.Model.MOrder newOrder = new VAdvantage.Model.MOrder(GetCtx(), 0, Get_Trx()); int orgId = Util.GetValueOfInt(dts.Tables[0].Rows[i]["AD_Org_Id"]); AddHeader(destinationorg, orgId); Addline(destinationorg, orgId); } } } else { //JID_1799 fromCreateSo is true if DOCBASETYPE='BOO' VAdvantage.Model.MOrder newOrder = VAdvantage.Model.MOrder.CopyFrom(from, _DateDoc, dt.GetC_DocType_ID(), false, true, null, dt.GetDocBaseType().Equals(MDocBaseType.DOCBASETYPE_BLANKETSALESORDER) ? true : false); // copy ASI newOrder.SetC_DocTypeTarget_ID(_C_DocType_ID); int C_Bpartner_ID = newOrder.GetC_BPartner_ID(); newOrder.Set_Value("IsSalesQuotation", false); // Added by Bharat on 05 Jan 2018 to set Values on Blanket Sales Order from Sales Quotation. if (dt.GetDocBaseType() == "BOO") { newOrder.Set_Value("IsBlanketTrx", true); } else // Added by Bharat on 29 March 2018 to set Blanket Order zero in case of Sales order Creation. { newOrder.SetC_Order_Blanket(0); } if (newOrder.Get_ColumnIndex("C_Order_Quotation") > 0) { newOrder.SetC_Order_Quotation(_C_Order_ID); } //Update New Order Refrence From Sales Qutation in Sales order newOrder.SetPOReference(Util.GetValueOfString(from.GetDocumentNo())); // Added by Bharat on 31 Jan 2018 to set Inco Term from Quotation if (newOrder.Get_ColumnIndex("C_IncoTerm_ID") > 0) { newOrder.SetC_IncoTerm_ID(from.GetC_IncoTerm_ID()); } String sqlbp = "update c_project set c_bpartner_id=" + C_Bpartner_ID + " where ref_order_id=" + _C_Order_ID + ""; int value = DB.ExecuteQuery(sqlbp, null, Get_Trx()); bool OK = newOrder.Save(); if (!OK) { //return GetReterivedError( newOrder, "Could not create new Order"); throw new Exception("Could not create new Order"); } if (OK) { string sql = "select C_Project_id from c_project where c_order_id = " + from.GetC_Order_ID(); int C_Project_ID = Util.GetValueOfInt(DB.ExecuteScalar(sql, null, Get_Trx())); if (C_Project_ID != 0) { VAdvantage.Model.X_C_Project project = new VAdvantage.Model.X_C_Project(GetCtx(), C_Project_ID, Get_Trx()); project.SetC_BPartner_ID(project.GetC_BPartnerSR_ID()); project.SetC_BPartnerSR_ID(0); if (!project.Save()) { log.SaveError("Error on " + project.Get_TableName(), ""); } } if (dt.GetDocBaseType() == "BOO") { from.SetC_Order_Blanket(newOrder.GetC_Order_ID()); } else { from.SetRef_Order_ID(newOrder.GetC_Order_ID()); } from.Save(); int bp = newOrder.GetC_BPartner_ID(); VAdvantage.Model.X_C_BPartner prosp = new VAdvantage.Model.X_C_BPartner(GetCtx(), bp, Get_Trx()); prosp.SetIsCustomer(true); prosp.SetIsProspect(false); if (!prosp.Save()) { log.SaveError("Error on " + prosp.Get_TableName(), ""); } } // if (_IsCloseDocument) { VAdvantage.Model.MOrder original = new VAdvantage.Model.MOrder(GetCtx(), _C_Order_ID, Get_Trx()); //Edited by Arpit Rai on 8th of Nov,2017 if (original.GetDocStatus() != "CO") //to check if document is already completed { original.SetDocAction(VAdvantage.Model.MOrder.DOCACTION_Complete); original.ProcessIt(VAdvantage.Model.MOrder.DOCACTION_Complete); original.Save(); } //Arpit original.SetDocAction(VAdvantage.Model.MOrder.DOCACTION_Close); original.ProcessIt(VAdvantage.Model.MOrder.DOCACTION_Close); original.Save(); } docNo = newOrder.GetDocumentNo(); } //+ ": " + newOrder.GetDocumentNo() return(Msg.GetMsg(GetCtx(), "OrderCreatedSuccessfully") + " - " + dt.GetName() + ": " + docNo); }
/// <summary> /// Perform Process. /// </summary> /// <returns>Message (clear text)</returns> protected override String DoIt() { //log.Info("C_Order_ID=" + _C_Order_ID // + ", C_DocType_ID=" + _C_DocType_ID // + ", CloseDocument=" + _IsCloseDocument); //if (_C_Order_ID == 0) //{ // throw new ArgumentException("No Order"); //} //MDocType dt = MDocType.Get(GetCtx(), _C_DocType_ID); //if (dt.Get_ID() == 0) //{ // throw new ArgumentException("No DocType"); //} //if (_DateDoc == null) //{ // _DateDoc = DateTime.Now; // //Util.GetValueOfDateTime(new DateTime(CommonFunctions.CurrentTimeMillis())); //} //// //MOrder from = new MOrder(GetCtx(), _C_Order_ID, Get_Trx()); //MOrder newOrder = MOrder.CopyFrom(from, _DateDoc, // dt.GetC_DocType_ID(), false, true, null); // copy ASI //newOrder.SetC_DocTypeTarget_ID(_C_DocType_ID); //bool OK = newOrder.Save (); //if (!OK) //{ // throw new Exception("Could not create new Order"); //} //// //if (_IsCloseDocument) //{ // MOrder original = new MOrder(GetCtx(), _C_Order_ID, Get_Trx()); // original.SetDocAction(MOrder.DOCACTION_Complete); // original.ProcessIt(MOrder.DOCACTION_Complete); // original.Save(); // original.SetDocAction(MOrder.DOCACTION_Close); // original.ProcessIt(MOrder.DOCACTION_Close); // original.Save(); //} //// //return dt.GetName() + ": " + newOrder.GetDocumentNo(); log.Info("C_Order_ID=" + _C_Order_ID + ", C_DocType_ID=" + _C_DocType_ID + ", CloseDocument=" + _IsCloseDocument); if (_C_Order_ID == 0) { throw new ArgumentException("No Order"); } VAdvantage.Model.MDocType dt = VAdvantage.Model.MDocType.Get(GetCtx(), _C_DocType_ID); if (dt.Get_ID() == 0) { throw new ArgumentException("No DocType"); } if (_DateDoc == null) { _DateDoc = Util.GetValueOfDateTime(DateTime.Now); } // VAdvantage.Model.MOrder from = new VAdvantage.Model.MOrder(GetCtx(), _C_Order_ID, Get_Trx()); MOrder newOrder = MOrder.CopyFrom(from, _DateDoc, dt.GetC_DocType_ID(), false, true, null, true);//Pass optional parameter as True that we are going to create Order from Create Sales Order Process on Sales Quotation window---Neha newOrder.SetC_DocTypeTarget_ID(_C_DocType_ID); //Update New Order Refrence From Sales Qutation in Sales order newOrder.SetPOReference(Util.GetValueOfString(from.GetDocumentNo())); int C_Bpartner_ID = newOrder.GetC_BPartner_ID(); newOrder.Set_Value("IsSalesQuotation", false); // Added by Bharat on 31 Jan 2018 to set Inco Term from Quotation if (newOrder.Get_ColumnIndex("C_IncoTerm_ID") > 0) { newOrder.SetC_IncoTerm_ID(from.GetC_IncoTerm_ID()); } String sqlbp = "update c_project set c_bpartner_id=" + C_Bpartner_ID + " where ref_order_id=" + _C_Order_ID + ""; int value = DB.ExecuteQuery(sqlbp, null, Get_Trx()); bool OK = newOrder.Save(); if (!OK) { throw new Exception("Could not create new Order"); } if (OK) { string sql = "select C_Project_id from c_project where c_order_id = " + from.GetC_Order_ID(); int C_Project_ID = Util.GetValueOfInt(DB.ExecuteScalar(sql, null, Get_Trx())); if (C_Project_ID != 0) { VAdvantage.Model.X_C_Project project = new VAdvantage.Model.X_C_Project(GetCtx(), C_Project_ID, Get_Trx()); project.SetC_BPartner_ID(project.GetC_BPartnerSR_ID()); project.SetC_BPartnerSR_ID(0); if (!project.Save()) { } } from.SetRef_Order_ID(newOrder.GetC_Order_ID()); from.Save(); int bp = newOrder.GetC_BPartner_ID(); VAdvantage.Model.X_C_BPartner prosp = new VAdvantage.Model.X_C_BPartner(GetCtx(), bp, Get_Trx()); prosp.SetIsCustomer(true); prosp.SetIsProspect(false); prosp.Save(); } // if (_IsCloseDocument) { VAdvantage.Model.MOrder original = new VAdvantage.Model.MOrder(GetCtx(), _C_Order_ID, Get_Trx()); //Edited by Arpit Rai on 8th of Nov,2017 if (original.GetDocStatus() != "CO") //to check if document is already completed { original.ProcessIt(VAdvantage.Model.MOrder.DOCACTION_Complete); original.SetDocAction(VAdvantage.Model.MOrder.DOCACTION_Complete); original.Save(); } //Arpit original.SetDocAction(VAdvantage.Model.MOrder.DOCACTION_Close); original.ProcessIt(VAdvantage.Model.MOrder.DOCACTION_Close); original.Save(); } // return(Msg.GetMsg(GetCtx(), "OrderCreatedSuccessfully") + " - " + dt.GetName() + ": " + newOrder.GetDocumentNo()); }
/** * Complete Document * @return new status (Complete, In Progress, Invalid, Waiting ..) */ public String CompleteIt() { // Re-Check if (!_justPrepared) { String status = PrepareIt(); if (!DocActionVariables.STATUS_INPROGRESS.Equals(status)) { return(status); } } // Implicit Approval if (!IsApproved()) { ApproveIt(); } log.Info(ToString()); // MInOut inout = new MInOut(GetCtx(), GetM_InOut_ID(), Get_TrxName()); MInOutLineConfirm[] lines = GetLines(false); // Check if we need to split Shipment if (IsInDispute()) { MDocType dt = MDocType.Get(GetCtx(), inout.GetC_DocType_ID()); if (dt.IsSplitWhenDifference()) { if (dt.GetC_DocTypeDifference_ID() == 0) { _processMsg = "No Split Document Type defined for: " + dt.GetName(); return(DocActionVariables.STATUS_INVALID); } SplitInOut(inout, dt.GetC_DocTypeDifference_ID(), lines); _lines = null; } } // All lines for (int i = 0; i < lines.Length; i++) { MInOutLineConfirm confirmLine = lines[i]; confirmLine.Set_TrxName(Get_TrxName()); if (!confirmLine.ProcessLine(inout.IsSOTrx(), GetConfirmType())) { _processMsg = "ShipLine not saved - " + confirmLine; return(DocActionVariables.STATUS_INVALID); } if (confirmLine.IsFullyConfirmed()) { confirmLine.SetProcessed(true); confirmLine.Save(Get_TrxName()); } else { if (CreateDifferenceDoc(inout, confirmLine)) { confirmLine.SetProcessed(true); confirmLine.Save(Get_TrxName()); } else { log.Log(Level.SEVERE, "Scrapped=" + confirmLine.GetScrappedQty() + " - Difference=" + confirmLine.GetDifferenceQty()); return(DocActionVariables.STATUS_INVALID); } } } // for all lines if (_creditMemo != null) { _processMsg += " @C_Invoice_ID@=" + _creditMemo.GetDocumentNo(); } if (_inventory != null) { _processMsg += " @M_Inventory_ID@=" + _inventory.GetDocumentNo(); } // User Validation String valid = ModelValidationEngine.Get().FireDocValidate(this, ModalValidatorVariables.DOCTIMING_AFTER_COMPLETE); if (valid != null) { _processMsg = valid; return(DocActionVariables.STATUS_INVALID); } SetProcessed(true); SetDocAction(DOCACTION_Close); return(DocActionVariables.STATUS_COMPLETED); }