public bool ReActivateIt() { try { log.Info(ToString()); MDocType dt = MDocType.Get(GetCtx(), GetC_DocType_ID()); String DocSubTypeSO = dt.GetDocSubTypeSO(); // Replace Prepay with POS to revert all doc if (MDocType.DOCSUBTYPESO_PrepayOrder.Equals(DocSubTypeSO)) { MDocType newDT = null; MDocType[] dts = MDocType.GetOfClient(GetCtx()); for (int i = 0; i < dts.Length; i++) { MDocType type = dts[i]; if (MDocType.DOCSUBTYPESO_PrepayOrder.Equals(type.GetDocSubTypeSO())) { if (type.IsDefault() || newDT == null) { newDT = type; } } } if (newDT == null) { return(false); } else { SetC_DocType_ID(newDT.GetC_DocType_ID()); //SetIsReturnTrx(newDT.IsReturnTrx()); } } // PO - just re-open //if (!IsSOTrx()) //{ // log.Info("Existing documents not modified - " + dt); //} // Reverse Direct Documents else if (MDocType.DOCSUBTYPESO_OnCreditOrder.Equals(DocSubTypeSO) || // (W)illCall(I)nvoice MDocType.DOCSUBTYPESO_WarehouseOrder.Equals(DocSubTypeSO) || // (W)illCall(P)ickup MDocType.DOCSUBTYPESO_POSOrder.Equals(DocSubTypeSO)) // (W)alkIn(R)eceipt { if (!CreateReversals()) { return(false); } } else { log.Info("Existing documents not modified - SubType=" + DocSubTypeSO); } SetDocAction(DOCACTION_Complete); SetProcessed(false); } catch { //ShowMessage.Error("MOrder", null, "SetBPartner"); } return(true); }
public string CompleteIt() { try { MDocType dt = MDocType.Get(GetCtx(), GetC_DocType_ID()); String DocSubTypeSO = dt.GetDocSubTypeSO(); // Just prepare if (DOCACTION_Prepare.Equals(GetDocAction())) { SetProcessed(false); return(DocActionVariables.STATUS_INPROGRESS); } //if (!IsReturnTrx()) //{ // // Offers // if (MDocType.DOCSUBTYPESO_Proposal.Equals(DocSubTypeSO) // || MDocType.DOCSUBTYPESO_Quotation.Equals(DocSubTypeSO)) // { // // Binding // if (MDocType.DOCSUBTYPESO_Quotation.Equals(DocSubTypeSO)) // ReserveStock(dt, GetLines(true, "M_Product_ID")); // SetProcessed(true); // SetDocAction(DOCACTION_Close); // return DocActionVariables.STATUS_COMPLETED; // } // // Waiting Payment - until we have a payment // if (!_forceCreation // && MDocType.DOCSUBTYPESO_PrepayOrder.Equals(DocSubTypeSO) // && GetC_Payment_ID() == 0 && GetC_CashLine_ID() == 0) // { // SetProcessed(true); // return DocActionVariables.STATUS_WAITINGPAYMENT; // } // // Re-Check // if (!_justPrepared) // { // String status = PrepareIt(); // if (!DocActionVariables.STATUS_INPROGRESS.Equals(status)) // return status; // } //} // Re-Check if (!_justPrepared) { String status = PrepareIt(); if (!DocActionVariables.STATUS_INPROGRESS.Equals(status)) { return(status); } } // Implicit Approval if (!IsApproved()) { ApproveIt(); } //GetLines(true, null); log.Info(ToString()); StringBuilder Info = new StringBuilder(); /* nnayak - Bug 1720003 - We need to set the processed flag so the Tax Summary Line * does not get recreated in the afterSave procedure of the MOrderLine class */ //bool realTimePOS = false; //// Create SO Shipment - Force Shipment //MInOut shipment = null; //if (MDocType.DOCSUBTYPESO_OnCreditOrder.Equals(DocSubTypeSO) // (W)illCall(I)nvoice // || MDocType.DOCSUBTYPESO_WarehouseOrder.Equals(DocSubTypeSO) // (W)illCall(P)ickup // || MDocType.DOCSUBTYPESO_POSOrder.Equals(DocSubTypeSO) // (W)alkIn(R)eceipt // || MDocType.DOCSUBTYPESO_PrepayOrder.Equals(DocSubTypeSO)) //{ // if (!DELIVERYRULE_Force.Equals(GetDeliveryRule())) // SetDeliveryRule(DELIVERYRULE_Force); // // // shipment = CreateShipment(dt, realTimePOS ? null : GetDateOrdered()); // if (shipment == null) // return DocActionVariables.STATUS_INVALID; // Info.Append("@M_InOut_ID@: ").Append(shipment.GetDocumentNo()); // String msg = shipment.GetProcessMsg(); // if (msg != null && msg.Length > 0) // Info.Append(" (").Append(msg).Append(")"); //} // Create SO Invoice - Always invoice complete Order //if (MDocType.DOCSUBTYPESO_POSOrder.Equals(DocSubTypeSO) // || MDocType.DOCSUBTYPESO_OnCreditOrder.Equals(DocSubTypeSO) // || MDocType.DOCSUBTYPESO_PrepayOrder.Equals(DocSubTypeSO)) //{ // try // { // DateTime? tSet = realTimePOS ? null : GetDateOrdered(); // MInvoice invoice = CreateInvoice(dt, shipment, tSet); // if (invoice == null) // return DocActionVariables.STATUS_INVALID; // Info.Append(" - @C_Invoice_ID@: ").Append(invoice.GetDocumentNo()); // String msg = invoice.GetProcessMsg(); // if (msg != null && msg.Length > 0) // Info.Append(" (").Append(msg).Append(")"); // } // catch (NullReferenceException ex) // { // //ShowMessage.Error("Moder",null,"Completeit"); // } //} // Counter Documents //MOrder counter = CreateCounterDoc(); //if (counter != null) // Info.Append(" - @CounterDoc@: @Order@=").Append(counter.GetDocumentNo()); ////User Validation //String valid = ModelValidationEngine.Get().FireDocValidate(this, ModalValidatorVariables.DOCTIMING_AFTER_COMPLETE); //if (valid != null) //{ // if (Info.Length > 0) // Info.Append(" - "); // Info.Append(valid); // _processMsg = Info.ToString(); // return DocActionVariables.STATUS_INVALID; //} bool msg = CheckForPreviousCompeletedRecords(); if (!msg) { return(DocActionVariables.STATUS_INVALID); // return _processMsg; } SetProcessed(true); _processMsg = Info.ToString(); SetDocAction(DOCACTION_Close); } catch { //ShowMessage.Error("MOrder",null,"CompleteIt"); } return(DocActionVariables.STATUS_COMPLETED); }