/// <summary> /// After Save /// </summary> /// <param name="newRecord">new</param> /// <param name="success">success</param> /// <returns>success</returns> protected override bool AfterSave(bool newRecord, bool success) { if (newRecord) { // SELECT Value FROM AD_Ref_List WHERE AD_Reference_ID=183 MDocType[] types = MDocType.GetOfClient(GetCtx()); int count = 0; List <String> baseTypes = new List <String>(); for (int i = 0; i < types.Length; i++) { MDocType type = types[i]; String docBaseType = type.GetDocBaseType(); if (baseTypes.Contains(docBaseType)) { continue; } MPeriodControl pc = new MPeriodControl(this, docBaseType); pc.SetAD_Org_ID(GetAD_Org_ID()); if (pc.Save()) { count++; } baseTypes.Add(docBaseType); } log.Fine("PeriodControl #" + count); } return(success); }
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); }