Revoke and Requisition Validation Replacement

--HG--
branch : EDII
This commit is contained in:
hodianto 2019-12-30 11:39:37 +07:00
parent 69fef3f01f
commit 12b02d878e
2 changed files with 83 additions and 37 deletions

View File

@ -1,5 +1,6 @@
package andromedia.midsuit.model;
import java.math.BigDecimal;
import java.sql.ResultSet;
import java.util.Properties;
@ -17,14 +18,17 @@ public class MID_MRequisitionLine extends MRequisitionLine{
*
*/
private static final long serialVersionUID = 978479235069420619L;
public MID_MRequisitionLine(MRequisition req) {
super(req);
// TODO Auto-generated constructor stub
}
public MID_MRequisitionLine(Properties ctx, int M_RequisitionLine_ID, String trxName) {
super(ctx, M_RequisitionLine_ID, trxName);
// TODO Auto-generated constructor stub
}
public MID_MRequisitionLine(Properties ctx, ResultSet rs, String trxName) {
super(ctx, rs, trxName);
// TODO Auto-generated constructor stub
@ -32,8 +36,8 @@ public class MID_MRequisitionLine extends MRequisitionLine{
@Override
protected boolean beforeSave(boolean newRecord) {
if(!newRecord){
MID_MRequisition requisition = new MID_MRequisition(getCtx(), getM_Requisition_ID(), get_TrxName());
if (!newRecord) {
Boolean isReactivate = requisition.get_ValueAsBoolean("IsReactivate");
if (isReactivate) {
if (is_ValueChanged("M_Product_ID")) {
@ -41,8 +45,48 @@ public class MID_MRequisitionLine extends MRequisitionLine{
}
}
}
return super.beforeSave(newRecord);
if (newRecord && getParent().isComplete()) {
log.saveError("ParentComplete", Msg.translate(getCtx(), "M_RequisitionLine"));
return false;
}
if (getLine() == 0) {
String sql = "SELECT COALESCE(MAX(Line),0)+10 FROM M_RequisitionLine WHERE M_Requisition_ID=?";
int ii = DB.getSQLValueEx(get_TrxName(), sql, getM_Requisition_ID());
setLine(ii);
}
// Product & ASI - Charge
if (getM_Product_ID() != 0 && getC_Charge_ID() != 0)
setC_Charge_ID(0);
if (getM_AttributeSetInstance_ID() != 0 && getC_Charge_ID() != 0)
setM_AttributeSetInstance_ID(0);
// Product UOM
if (getM_Product_ID() > 0 && getC_UOM_ID() <= 0) {
setC_UOM_ID(getM_Product().getC_UOM_ID());
}
//
if (getPriceActual().signum() == 0)
setPrice();
this.setLineNetAmt(requisition.getC_Currency_ID());
/*
* Carlos Ruiz - globalqss IDEMPIERE-178 Orders and Invoices must disallow
* amount lines without product/charge
*/
if (getParent().getC_DocType().isChargeOrProductMandatory()) {
if (getC_Charge_ID() == 0 && getM_Product_ID() == 0 && getPriceActual().signum() != 0) {
log.saveError("FillMandatory", Msg.translate(getCtx(), "ChargeOrProductMandatory"));
return false;
}
}
return true;
}
public void setLineNetAmt (int C_Currency_ID)
{
BigDecimal lineNetAmt = getQty().multiply(getPriceActual());
int StdPrecision = DB.getSQLValue(get_TrxName(), "SELECT StdPrecision FROM C_Currency WHERE C_Currency_ID =?", new Object[] { C_Currency_ID });
super.setLineNetAmt (lineNetAmt.setScale(StdPrecision, BigDecimal.ROUND_HALF_UP));
} // setLineNetAmt
@Override
protected boolean beforeDelete() {
MID_MRequisition requisition = new MID_MRequisition(getCtx(), getM_Requisition_ID(), get_TrxName());
@ -53,6 +97,7 @@ public class MID_MRequisitionLine extends MRequisitionLine{
}
return super.beforeDelete();
}
@Override
protected boolean afterSave(boolean newRecord, boolean success) {
String sql = "UPDATE M_Requisition SET TaxAmt = "
@ -124,5 +169,4 @@ public class MID_MRequisitionLine extends MRequisitionLine{
return super.afterDelete(success);
}
}

View File

@ -16,9 +16,7 @@ public class MID_PEBRevoke extends SvrProcess {
@Override
protected String doIt() throws Exception {
pebLine.setProcessed(false);
pebLine.setC_Order_ID(0);
pebLine.saveEx();
MID_MOrder order = new MID_MOrder(getCtx(), pebLine.getC_Order_ID(), get_TrxName());
order.set_ValueNoCheck("RegisterDate", null);
@ -26,7 +24,11 @@ public class MID_PEBRevoke extends SvrProcess {
order.set_ValueNoCheck("NoAju1", null);
order.set_ValueNoCheck("MID_AJUDocumentType_ID", null);
order.saveEx();
return EMPTY_STRING;
pebLine.setProcessed(false);
pebLine.setC_Order_ID(0);
pebLine.saveEx();
return "Revoke Custom Success!";
}
}