protected override bool BeforeSave(bool newRecord) { MJournalLine obj = new MJournalLine(GetCtx(), GetGL_JournalLine_ID(), Get_Trx()); // In Case of reversal, bypass this condition if (!(obj.Get_ColumnIndex("ReversalDoc_ID") > 0 && obj.GetReversalDoc_ID() > 0)) { string val = ""; if (obj.GetAmtSourceDr() > 0) { val = " AmtSourceDr "; } else { val = " AmtSourceCr "; } string sql = "SELECT SUM(amount) FROM Gl_Linedimension WHERE GL_JournalLine_ID=" + Get_Value("GL_JournalLine_ID") + " AND Gl_Linedimension_ID NOT IN( " + GetGL_LineDimension_ID() + ")"; Decimal count = Util.GetValueOfDecimal(DB.ExecuteScalar(sql, null, Get_Trx())); count += GetAmount(); sql = "SELECT " + val + " FROM GL_JournalLine WHERE GL_JournalLine_ID=" + Get_Value("GL_JournalLine_ID"); Decimal amtcount = Util.GetValueOfDecimal(DB.ExecuteScalar(sql, null, Get_Trx())); if (count > amtcount) { log.SaveWarning("AmoutCheck", ""); return(false); } } return(true); }