BF [ 1883533 ] Change to summary - valid combination issue

BF [ 2320411 ] Translate "Already posted to" message
This commit is contained in:
teo_sarca 2008-11-21 12:30:46 +00:00
parent aa23ca0ffa
commit d8ef615ee2
3 changed files with 66 additions and 27 deletions

View File

@ -16,15 +16,21 @@
*****************************************************************************/ *****************************************************************************/
package org.compiere.model; package org.compiere.model;
import java.sql.*; import java.sql.ResultSet;
import java.util.*; import java.util.Properties;
import org.compiere.util.*;
import org.adempiere.exceptions.AdempiereException;
import org.compiere.util.Env;
/** /**
* Natural Account * Natural Account
* *
* @author Jorg Janke * @author Jorg Janke
* @version $Id: MElementValue.java,v 1.3 2006/07/30 00:58:37 jjanke Exp $ * @version $Id: MElementValue.java,v 1.3 2006/07/30 00:58:37 jjanke Exp $
*
* @author Teo Sarca, SC ARHIPAC SERVICE SRL
* BF [ 1883533 ] Change to summary - valid combination issue
* BF [ 2320411 ] Translate "Already posted to" message
*/ */
public class MElementValue extends X_C_ElementValue public class MElementValue extends X_C_ElementValue
{ {
@ -191,36 +197,43 @@ public class MElementValue extends X_C_ElementValue
/** @Override
* Before Save
* @param newRecord
* @return true if ir can be saved
*/
protected boolean beforeSave (boolean newRecord) protected boolean beforeSave (boolean newRecord)
{ {
if (getAD_Org_ID() != 0) if (getAD_Org_ID() != 0)
setAD_Org_ID(0); setAD_Org_ID(0);
// //
if (!newRecord && isSummary() // Transform to summary level account
&& is_ValueChanged("IsSummary")) if (!newRecord && isSummary() && is_ValueChanged(COLUMNNAME_IsSummary))
{ {
String sql = "SELECT COUNT(*) FROM Fact_Acct WHERE Account_ID=?"; //
int no = DB.getSQLValue(get_TrxName(), sql, getC_ElementValue_ID()); // Check if we have accounting facts
if (no != 0) boolean match = new Query(getCtx(), MFactAcct.Table_Name, MFactAcct.COLUMNNAME_Account_ID+"=?", get_TrxName())
.setParameters(new Object[]{getC_ElementValue_ID()})
.match();
if (match)
{ {
log.saveError("Error", "Already posted to"); throw new AdempiereException("@AlreadyPostedTo@");
return false; }
//
// Check Valid Combinations - teo_sarca FR [ 1883533 ]
String whereClause = MAccount.COLUMNNAME_Account_ID+"=?";
POResultSet<MAccount> rs = new Query(getCtx(), MAccount.Table_Name, whereClause, get_TrxName())
.setParameters(new Object[]{get_ID()})
.scroll();
try {
while(rs.hasNext()) {
rs.next().deleteEx(true);
}
}
finally {
rs.close();
} }
} }
return true; return true;
} // beforeSave } // beforeSave
/** @Override
* After Save
* @param newRecord new
* @param success success
* @return success
*/
protected boolean afterSave (boolean newRecord, boolean success) protected boolean afterSave (boolean newRecord, boolean success)
{ {
if (newRecord) if (newRecord)
@ -234,7 +247,7 @@ public class MElementValue extends X_C_ElementValue
} }
// Value/Name change // Value/Name change
if (!newRecord && (is_ValueChanged("Value") || is_ValueChanged("Name"))) if (!newRecord && (is_ValueChanged(COLUMNNAME_Value) || is_ValueChanged(COLUMNNAME_Name)))
{ {
MAccount.updateValueDescription(getCtx(), "Account_ID=" + getC_ElementValue_ID(),get_TrxName()); MAccount.updateValueDescription(getCtx(), "Account_ID=" + getC_ElementValue_ID(),get_TrxName());
if ("Y".equals(Env.getContext(getCtx(), "$Element_U1"))) if ("Y".equals(Env.getContext(getCtx(), "$Element_U1")))
@ -246,11 +259,7 @@ public class MElementValue extends X_C_ElementValue
return success; return success;
} // afterSave } // afterSave
/** @Override
* After Delete
* @param success
* @return deleted
*/
protected boolean afterDelete (boolean success) protected boolean afterDelete (boolean success)
{ {
if (success) if (success)

View File

@ -0,0 +1,15 @@
-- 21.11.2008 14:21:33 EET
-- BF [ 2320411 ] Translate "Already posted to" message
INSERT INTO AD_Message (AD_Client_ID,AD_Message_ID,AD_Org_ID,Created,CreatedBy,EntityType,IsActive,MsgText,MsgType,Updated,UpdatedBy,Value) VALUES (0,53046,0,TO_DATE('2008-11-21 14:21:30','YYYY-MM-DD HH24:MI:SS'),0,'D','Y','Already posted to this account.','E',TO_DATE('2008-11-21 14:21:30','YYYY-MM-DD HH24:MI:SS'),0,'AlreadyPostedTo')
;
-- 21.11.2008 14:21:33 EET
-- BF [ 2320411 ] Translate "Already posted to" message
INSERT INTO AD_Message_Trl (AD_Language,AD_Message_ID, MsgText,MsgTip, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy) SELECT l.AD_Language,t.AD_Message_ID, t.MsgText,t.MsgTip, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy FROM AD_Language l, AD_Message t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Message_ID=53046 AND EXISTS (SELECT * FROM AD_Message_Trl tt WHERE tt.AD_Language!=l.AD_Language OR tt.AD_Message_ID!=t.AD_Message_ID)
;
-- 21.11.2008 14:22:08 EET
-- BF [ 2320411 ] Translate "Already posted to" message
UPDATE AD_Message_Trl SET IsTranslated='Y',MsgText='Exista inregistrari contabile pe acest cont.',Updated=TO_DATE('2008-11-21 14:22:08','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=0 WHERE AD_Message_ID=53046 AND AD_Language='ro_RO'
;

View File

@ -0,0 +1,15 @@
-- 21.11.2008 14:21:33 EET
-- BF [ 2320411 ] Translate "Already posted to" message
INSERT INTO AD_Message (AD_Client_ID,AD_Message_ID,AD_Org_ID,Created,CreatedBy,EntityType,IsActive,MsgText,MsgType,Updated,UpdatedBy,Value) VALUES (0,53046,0,TO_TIMESTAMP('2008-11-21 14:21:30','YYYY-MM-DD HH24:MI:SS'),0,'D','Y','Already posted to this account.','E',TO_TIMESTAMP('2008-11-21 14:21:30','YYYY-MM-DD HH24:MI:SS'),0,'AlreadyPostedTo')
;
-- 21.11.2008 14:21:33 EET
-- BF [ 2320411 ] Translate "Already posted to" message
INSERT INTO AD_Message_Trl (AD_Language,AD_Message_ID, MsgText,MsgTip, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy) SELECT l.AD_Language,t.AD_Message_ID, t.MsgText,t.MsgTip, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy FROM AD_Language l, AD_Message t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Message_ID=53046 AND EXISTS (SELECT * FROM AD_Message_Trl tt WHERE tt.AD_Language!=l.AD_Language OR tt.AD_Message_ID!=t.AD_Message_ID)
;
-- 21.11.2008 14:22:08 EET
-- BF [ 2320411 ] Translate "Already posted to" message
UPDATE AD_Message_Trl SET IsTranslated='Y',MsgText='Exista inregistrari contabile pe acest cont.',Updated=TO_TIMESTAMP('2008-11-21 14:22:08','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=0 WHERE AD_Message_ID=53046 AND AD_Language='ro_RO'
;