BF [2910289] - More on RMA Stabilization

https://sourceforge.net/tracker/?func=detail&aid=2910289&group_id=176962&atid=879332
Refactor for a better approach (update directly via SQL to avoid overload of change log and all the stuff of PO - like invoiceline)
This commit is contained in:
Carlos Ruiz 2009-12-07 21:30:27 +00:00
parent 4481f00b5d
commit 9ff1e954c7
1 changed files with 28 additions and 20 deletions

View File

@ -36,7 +36,7 @@ public class MRMALine extends X_M_RMALine
/** /**
* *
*/ */
private static final long serialVersionUID = -4939372209739721247L; private static final long serialVersionUID = 7542507297588438252L;
/** /**
* Standard Constructor * Standard Constructor
@ -291,15 +291,7 @@ public class MRMALine extends X_M_RMALine
return success; return success;
} }
MRMA rma = getParent(); return updateHeaderAmt();
rma.updateAmount();
if (!rma.save(get_TrxName()))
{
throw new IllegalStateException("Could not update RMA grand total");
}
return true;
} }
@Override @Override
@ -310,17 +302,33 @@ public class MRMALine extends X_M_RMALine
return success; return success;
} }
MRMA rma = getParent(); return updateHeaderAmt();
rma.updateAmount();
if (!rma.save(get_TrxName()))
{
throw new IllegalStateException("Could not update RMA grand total");
}
return true;
} }
/**
* Update Amount on Header
* @return true if header updated
*/
private boolean updateHeaderAmt()
{
// Update header only if the document is not processed
if (isProcessed() && !is_ValueChanged(COLUMNNAME_Processed))
return true;
// Update RMA Header
String sql = "UPDATE M_RMA "
+ " SET Amt="
+ "(SELECT COALESCE(SUM(LineNetAmt),0) FROM M_RMALine WHERE M_RMA.M_RMA_ID=M_RMALine.M_RMA_ID) "
+ "WHERE M_RMA_ID=?";
int no = DB.executeUpdateEx(sql, new Object[]{getM_RMA_ID()}, get_TrxName());
if (no != 1)
log.warning("(1) #" + no);
m_parent = null;
return no == 1;
} // updateHeaderTax
/** /**
* Add to Description * Add to Description
* @param description text * @param description text