BF [ 1961491 ] Payment Term Schedule : In/Active valid / >100% cant delete

This commit is contained in:
teo_sarca 2008-05-11 10:05:48 +00:00
parent 33abd518c2
commit e3f2673e7f
2 changed files with 19 additions and 3 deletions

View File

@ -88,7 +88,7 @@ public class MPaySchedule extends X_C_PaySchedule
*/ */
protected boolean beforeSave (boolean newRecord) protected boolean beforeSave (boolean newRecord)
{ {
if (is_ValueChanged("Percentage")) if (is_ValueChanged("Percentage") || is_ValueChanged("IsActive"))
{ {
log.fine("beforeSave"); log.fine("beforeSave");
setIsValid(false); setIsValid(false);
@ -104,7 +104,7 @@ public class MPaySchedule extends X_C_PaySchedule
*/ */
protected boolean afterSave (boolean newRecord, boolean success) protected boolean afterSave (boolean newRecord, boolean success)
{ {
if (newRecord || is_ValueChanged("Percentage")) if (newRecord || is_ValueChanged("Percentage") || is_ValueChanged("IsActive"))
{ {
log.fine("afterSave"); log.fine("afterSave");
getParent(); getParent();
@ -114,4 +114,15 @@ public class MPaySchedule extends X_C_PaySchedule
return success; return success;
} // afterSave } // afterSave
@Override
protected boolean afterDelete(boolean success) {
if (!success)
return false;
getParent();
m_parent.validate();
m_parent.save();
return true;
}
} // MPaySchedule } // MPaySchedule

View File

@ -80,7 +80,7 @@ public class MPaymentTerm extends X_C_PaymentTerm
{ {
if (m_schedule != null && !requery) if (m_schedule != null && !requery)
return m_schedule; return m_schedule;
String sql = "SELECT * FROM C_PaySchedule WHERE C_PaymentTerm_ID=? ORDER BY NetDays"; String sql = "SELECT * FROM C_PaySchedule WHERE C_PaymentTerm_ID=? AND IsActive='Y' ORDER BY NetDays";
ArrayList<MPaySchedule> list = new ArrayList<MPaySchedule>(); ArrayList<MPaySchedule> list = new ArrayList<MPaySchedule>();
PreparedStatement pstmt = null; PreparedStatement pstmt = null;
try try
@ -133,6 +133,11 @@ public class MPaymentTerm extends X_C_PaymentTerm
if (m_schedule.length == 1) if (m_schedule.length == 1)
{ {
setIsValid(false); setIsValid(false);
if (m_schedule[0].isValid())
{
m_schedule[0].setIsValid(false);
m_schedule[0].save();
}
return "@Invalid@ @Count@ # = 1 (@C_PaySchedule_ID@)"; return "@Invalid@ @Count@ # = 1 (@C_PaySchedule_ID@)";
} }